Skip to content

Prevent re-opening websocket connections on metadata update#3093

Merged
shengquan-ni merged 4 commits into
masterfrom
shengquan-fix-duplicated-console
Nov 20, 2024
Merged

Prevent re-opening websocket connections on metadata update#3093
shengquan-ni merged 4 commits into
masterfrom
shengquan-fix-duplicated-console

Conversation

@shengquan-ni

@shengquan-ni shengquan-ni commented Nov 20, 2024

Copy link
Copy Markdown
Contributor

This PR fixes #3085. The issue is caused by a call of this.workflowActionService.setWorkflowMetadata(updatedWorkflow); in persistWorkflow. This call caused the WebSocket service to detect a workflow metadata update and reopen the WebSocket unnecessarily. Therefore, the bug can be consistently reproduced by hitting the save button on the workflow canvas.

This PR introduces a logic check to skip reopening the WebSocket if the wid remains unchanged, preventing redundant reconnections.

@aglinxinyuan aglinxinyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shengquan-ni shengquan-ni changed the title Prevent re-open websocket connections on metadata update Prevent re-opening websocket connections on metadata update Nov 20, 2024
@shengquan-ni shengquan-ni merged commit 333a5b2 into master Nov 20, 2024
@shengquan-ni shengquan-ni deleted the shengquan-fix-duplicated-console branch November 20, 2024 22:37
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
This PR fixes #3085. The issue is caused by a call of
`this.workflowActionService.setWorkflowMetadata(updatedWorkflow);` in
`persistWorkflow`. This call caused the WebSocket service to detect a
workflow metadata update and reopen the WebSocket unnecessarily.
Therefore, the bug can be consistently reproduced by hitting the save
button on the workflow canvas.

This PR introduces a logic check to skip reopening the WebSocket if the
wid remains unchanged, preventing redundant reconnections.
@Yicong-Huang Yicong-Huang added fix and removed bug labels Oct 4, 2025
SarahAsad23 pushed a commit to madisonmlin/texera that referenced this pull request May 20, 2026
)

This PR fixes apache#3085. The issue is caused by a call of
`this.workflowActionService.setWorkflowMetadata(updatedWorkflow);` in
`persistWorkflow`. This call caused the WebSocket service to detect a
workflow metadata update and reopen the WebSocket unnecessarily.
Therefore, the bug can be consistently reproduced by hitting the save
button on the workflow canvas.

This PR introduces a logic check to skip reopening the WebSocket if the
wid remains unchanged, preventing redundant reconnections.
kunwp1 added a commit to kunwp1/texera that referenced this pull request Jun 8, 2026
…rd (apache#3120)

WorkflowWebsocketService, ComputingUnitStatusService, and the execution-session services (WorkflowStatusService, ExecuteWorkflowService, WorkflowConsoleService, WorkflowResultService) are all root-scoped singletons, so their state outlived the workspace. WorkspaceComponent.ngOnDestroy cleared the workflow graph but never tore down the websocket session, leaving the socket open and the derived state (connection tracking, worker count, execution status, console output, result caches) populated. Re-entering a workflow then reused the stale session; for the same wid (the wid -> null -> wid pattern) the reconnect guard even short-circuited, the case PR apache#3093's in-canvas guard did not cover.

Tear down every piece of websocket-derived state on workspace destroy: ComputingUnitStatusService.disconnect() (close socket, clear status, stop polling, reset connection tracking and selected unit), WorkflowWebsocketService.closeWebsocket() (reset numWorkers), ExecuteWorkflowService.resetState() (execution state + worker assignments), WorkflowConsoleService.clearConsoleMessages(), and WorkflowResultService.clearResults() (result caches + table-stats ReplaySubject). WorkspaceComponent.ngOnDestroy invokes all of them so re-entering any workflow (same wid included) starts from a clean session.
zyratlo pushed a commit to zyratlo/texera that referenced this pull request Jun 9, 2026
…rd (apache#5565)

### What changes were proposed in this PR?

Websocket-derived front-end state (the connection itself, plus the
execution status, console output, and results built from its events)
lives in singletons outside the workspace. It was never torn down in two
cases, so stale state carried over:

1. **Returning to the dashboard** and re-entering a workflow reused the
previous socket. The connection-tracking fields (`currentConnectedWid` /
`currentConnectedCuid`) also survived, so the reconnect guard saw them
unchanged, skipped reconnecting, and reused the stale socket. (apache#3120 —
the case apache#3093 did not cover.)
2. **Switching computing units** inside the workspace left the previous
unit's console, results, and execution status on screen.

This PR clears that state at both points.

**Workspace exit**: `WorkspaceComponent.ngOnDestroy()` now tears
everything down:

| Call *(new)* | Resets |
| --- | --- |
| `ComputingUnitStatusService.disconnect()` | closes the socket, clears
operator status, stops the unit poll, resets the connection-tracking
fields and the selected unit |
| `ExecuteWorkflowService.resetExecutionAndWorkers()` | execution status
and worker assignments |
| `WorkflowConsoleService.clearConsoleMessages()` | console output |
| `WorkflowResultService.clearResults()` | result caches and table stats
|

**Unit switch**: `ComputingUnitStatusService` emits a reset signal when
it reconnects to a different unit, and `WorkspaceComponent` clears the
same execution / console / result state in response. As a result,
switching units now discards the previous unit's results and console
instead of leaving them on screen.

The remaining websocket-event consumers need no teardown:
`OperatorReuseCacheStatusService` is stateless, and
`udf-debug.service`'s state lives in the `TexeraGraph`, already reset by
`clearWorkflow()`.

### Any related issues, documentation, discussions?

Closes apache#3120. Related: apache#3093 (earlier partial fix for the in-canvas
socket re-open).

### How was this PR tested?

Test with this workflow
[Untitled workflow
(14).json](https://github.com/user-attachments/files/28696700/Untitled.workflow.14.json)


https://github.com/user-attachments/assets/060fe1ac-39cf-45e5-b423-5aa27fe17aed



### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.8)

---------

Co-authored-by: Xinyuan Lin <xinyual3@uci.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate console logs

3 participants