Skip to content

Fix parDemuxScan deadlock when worker throws with full buffer#3189

Open
johnhampton wants to merge 1 commit intocomposewell:masterfrom
topagentnetwork:deadlock-fix
Open

Fix parDemuxScan deadlock when worker throws with full buffer#3189
johnhampton wants to merge 1 commit intocomposewell:masterfrom
topagentnetwork:deadlock-fix

Conversation

@johnhampton
Copy link

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).

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
@harendra-kumar
Copy link
Member

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

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