Skip to content

Exit instead of hanging when the output can't be written - #33

Open
DylanCosto wants to merge 1 commit into
mainfrom
fix-broken-pipe-hang
Open

DylanCosto wants to merge 1 commit into
mainfrom
fix-broken-pipe-hang

Conversation

@DylanCosto

Copy link
Copy Markdown
Owner

If bonefish couldn't write its output (downstream `samtools sort` killed, disk full, piped into `head`) and there were still reads left to read, it hung at 0% CPU instead of exiting. The reader thread stayed blocked on the full read-ahead queue, and the thread scope waited for it forever. This has been present since v0.1.0. Alignments are never affected, but a failed pipeline step holds its node until the job's time limit.

Fix:

  • When the writer stops, the read-ahead queue is now dropped, so the blocked reader exits.
  • Workers skip the reads still queued.

bonefish now exits within a few seconds with exit code 1 and the error ("Broken pipe", "No space left on device").

Tests:

  • New regression test `closed_output_pipe_exits`: it hangs for 60 s and fails without the fix, and passes in 0.1 s with it.
  • Golden outputs are unchanged, and clippy is clean.
  • Checked by hand:
    • SAM and PAF piped into `head`;
    • stdin input;
    • writing to `/dev/full`, both SAM and `-o` sorted BAM.

🤖 Generated with Claude Code

When a write failed (output pipe closed, disk full) with input still
left to read, the reader thread stayed blocked on the full read-ahead
queue and the thread scope waited for it forever. The queue is now
dropped once the writer stops, so the reader exits, and workers skip
reads still queued. Present since v0.1.0. Output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant