Skip to content

Report a failed block's error instead of the cancellation it causes - #34

Open
tamirms wants to merge 1 commit into
build-from-sorted-filesfrom
build-block-error
Open

tamirms wants to merge 1 commit into
build-from-sorted-filesfrom
build-block-error

Conversation

@tamirms

@tamirms tamirms commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

In a parallel SortedBuilder or UnsortedBuilder build, a block that fails to build cancels the workers' context and reaches the writer, which reports the failure. The goroutine dispatching blocks waits on both, and when it saw the context first it returned context.Canceled instead of the failure. A build with a duplicate key in its first block returned context.Canceled about one time in eight, so a caller checking for ErrDuplicateKey missed it.

  • The dispatcher, in dispatchBlockWork and in the unsorted builder's parallel finish, now returns the context's cause: the error of the worker or writer that failed, or the build context's error when the caller canceled the build.
  • The writer now cancels the workers with its error as the cause. Its own errors need that, and so does a block's error when the writer's cancel lands before the failed worker's, which 9 of 14,000 sorted builds did under stress.

The teardown fuzz harness's duplicate-key scenario now requires ErrDuplicateKey and no longer accepts context.Canceled. The old code failed it 15 times in 3 runs.

🤖 Generated with Claude Code

In a parallel SortedBuilder or UnsortedBuilder build, a block that fails
cancels the workers' context and reaches the writer, which reports it on
writerDone. The goroutine dispatching blocks waits on both, and when it
saw the context first it returned context.Canceled: about one build in
eight with a duplicate key in its first block did. It now returns the
context's cause, which is the failure's error, or the build context's
error when the build was canceled. The writer now cancels with its error
as the cause. Its own errors need that, and so does a block's error when
the writer's cancel lands before the failed worker's, which 9 of 14,000
sorted builds did under stress. The teardown harness's duplicate-key
scenario no longer accepts context.Canceled; the old code failed it 15
times in 3 runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DjQed1VX9uGU9PWpAjBiz7
@tamirms
tamirms added this pull request to stack #36 October 26, 2026 08:00
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