Skip to content

Fix parDemuxScan deadlock when worker throws with full buffer - #3189

Merged
harendra-kumar merged 1 commit into
composewell:masterfrom
topagentnetwork:deadlock-fix
Apr 19, 2026
Merged

harendra-kumar merged 1 commit into
composewell:masterfrom
topagentnetwork:deadlock-fix

Conversation

@johnhampton

Copy link
Copy Markdown
Contributor

When a fold worker throws an exception while the driver is blocked on a full input buffer, sendExceptionToDriver writes to the output queue but never signals the driver. The driver remains stuck on takeMVar, and GHC's runtime eventually throws BlockedIndefinitelyOnMVar, masking the original exception entirely.

Signal inputSpaceDoorBell and set closedForInput in sendExceptionToDriver so the driver can wake up. Add regression test.

This fix was implemented with AI assistance (Claude, Anthropic).

@harendra-kumar

Copy link
Copy Markdown
Member

Thanks for the PR @johnhampton . I will take a deeper look and get back to you.

@harendra-kumar

Copy link
Copy Markdown
Member

@johnhampton I have fixed the failing CIs on master, you can rebase this on master.

Signal the driver thread when a worker exception occurs so it can wake
up from blocking on a full input buffer. Previously sendExceptionToDriver
only wrote to the output queue, leaving the driver stuck on takeMVar.

- Set closedForInput and signal inputSpaceDoorBell in sendExceptionToDriver
- Add regression test with slow single-key worker that throws mid-stream
- Test confirms original exception propagates instead of BlockedIndefinitelyOnMVar
@johnhampton

johnhampton commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@harendra-kumar I've rebased and all the tests pass. I'm sorry for the delay, I missed the GitHub notification.

@harendra-kumar

Copy link
Copy Markdown
Member

Thanks @johnhampton . I am merging this.

@harendra-kumar
harendra-kumar merged commit 670399b into composewell:master Apr 19, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants