The GitHub Actions job "Required Checks" on 
texera.git/backport/7914-shutdown-console-writer-thread-on-unsubs-v1.2 has 
failed.
Run started by GitHub user github-actions[bot] (triggered by 
github-actions[bot]).

Head commit for run:
17f47cd398a495e9caeef228e0afa3ec3549bda3 / Martin Vu 
<[email protected]>
fix(WorkflowExecutionService): shutdown console writer thread on unsubscribe 
(#7914)

### What changes were proposed in this PR?

Fixes a console writer thread leak in `ExecutionConsoleService`.

The console writer executor was not being shut down when an execution
service was unsubscribed. This could leave `texera-console-writer`
threads alive after workflow execution finished.

Before:
<img width="1240" height="60" alt="Screenshot 2026-08-23 at 11 40 04 PM"
src="https://github.com/user-attachments/assets/d199f3c0-a463-4645-addf-a5dc2ee456d8";
/>

After:
<img width="1348" height="48" alt="Screenshot 2026-08-23 at 6 40 25 PM"
src="https://github.com/user-attachments/assets/a2e0c9bc-607f-451f-bccb-ec4ea4315a96";
/>

<img width="1348" height="60" alt="Screenshot 2026-08-23 at 6 41 53 PM"
src="https://github.com/user-attachments/assets/3d7742ef-db7a-4790-a43d-d8b5bfa69d58";
/>
<img width="1348" height="60" alt="Screenshot 2026-08-23 at 6 42 18 PM"
src="https://github.com/user-attachments/assets/c2e7a6d6-e516-4dd1-8ed9-7d6cccf22f1f";
/>

<img width="1348" height="60" alt="Screenshot 2026-08-23 at 6 42 42 PM"
src="https://github.com/user-attachments/assets/084bed9e-1338-4e27-9563-ad22708d75aa";
/>
<img width="1348" height="60" alt="Screenshot 2026-08-23 at 6 42 55 PM"
src="https://github.com/user-attachments/assets/ee11bcca-35fa-453e-91e2-8f3e06065c1d";
/>

This PR:
- Shuts down the console writer executor during `unsubscribeAll()`.
- Waits for termination and falls back to `shutdownNow()` if necessary.
- Closes active console message writers and clears the writer map.
- Adds a test verifying the console writer executor is shut down and
terminated.

### Any related issues, documentation, discussions?

Fixes #7455

### How was this PR tested?

Ran:
```bash
sbt "project WorkflowExecutionService" "testOnly *ExecutionConsoleServiceSpec 
-- -z unsubscribeAll"
```
Manual testing:

Ran workflows multiple times and checked the console writer threads
with:
```bash
jcmd 57436 Thread.print | grep "texera-console-writer"
```
```bash
jcmd 67548 Thread.print | grep "texera-console-writer"
```
Verified that the console writer threads are terminated after workflow
execution completes and unsubscribeAll() is called.

### Was this PR authored or co-authored using generative AI tooling?
Generated-by: ChatGPT (5.5 mini)

(backported from commit bdc6d2a90eb1415014a4f705b7bb7cca31bb9688)

Report URL: https://github.com/apache/texera/actions/runs/33140257649

With regards,
GitHub Actions via GitBox

Reply via email to