Skip to content

flow: losses in a flow's shuffle (PR 2 of the keyed-partitions plan) - #177

Merged
winding-lines merged 1 commit into
mainfrom
flow-partition-loss
Nov 29, 2026
Merged

winding-lines merged 1 commit into
mainfrom
flow-partition-loss

Conversation

@winding-lines

Copy link
Copy Markdown
Contributor

PR 2 of "Keyed partitions in flows (plan, 2026-11-29)" in DESIGN.md: losses.

What was built

  • Before the barrier, a loss reads the input again. The barrier's piece check (FlowRun._partition) turns a lost piece (is_loss) into a rerun of that input, and keeps raising for any other error. A partition task's own loss (its worker gone while it ran) reruns its input too, from _advance's scan of finished tasks. Both count in the Partition's reruns and stay within the flow's retries. _rerun now also takes the input's partition task out of the running list (abandoned, released once settled) and releases every piece of that attempt, pieces 1 to parts-1 included.
  • After the barrier, a loss fails the flow with a clear message naming the operator and the partition, from _advance (reducers and later Maps) and from next's partition branch: operator 2 (Reduce m::merge) failed on partition 1: input failed: result … lost: …; lost after the reducers started, which a flow doesn't rerun: run the flow again. Everything is released, as before.
  • Bytes per partition in stats: FlowStats.partition_bytes (and unsized_pieces), counted when the barrier passes, from the new Client.size_of. Inline pieces' sizes are known without fetching too, because the driver keeps their bytes; stored ones come from the located frame.
  • A head fix the gate found: a restarted head adopting a re-sent TaskMany whose results a rejoining worker had already reported delivered only the first result and dropped the others. The partition flow in head_restart.sh failed with "an input was released before this task ran" in 3 of 4 runs before the fix.
  • Flows without a Partition run the same code as before (_rerun's and the barrier's new branches are comptime if Self.P >= 0). FlowStats.write_to prints nothing new for them. No public name or signature changed; FlowStats.__init__ gained two defaulted arguments.

Gate and tests

  • tests/flow_loss.sh now runs three cases: map (the old one), partition (the worker with the most pieces, other than the one whose partition task waits, is killed before the barrier: exact, with reruns at the Partition), and reduce (killed while the first of one-at-a-time reducers waits: the flow fails with the message, and the head holds nothing).
  • tests/head_restart.sh: a group-by flow on two workers of a new group shuffle. The head is killed while the driver is inside its next, before its barrier; it must come out exact, and the driver checks that the restart happened during that next. tests/cli.sh starts two shuffle workers for the same driver.
  • tests/test_flow_partition.mojo: a partition task that kills its worker once reruns its input, with exact results; one that kills it every time fails after its retries; the group-by test checks partition_bytes.

Verified

  • Mac: flow_loss.sh 6/6 passes (all three cases each time), head_restart.sh 6/6, test_flow_partition, test_flow, test_shuffle, format-check, and the full pixi run test (results in a comment below).
  • sai (Linux x86-64): results in a comment below.

Deviations (recorded in DESIGN.md, "PR 2, as built")

  • The message after the barrier is the loss dista reports plus a suffix, not the plan's exact wording, since what was lost may be the reducer's own worker rather than a piece.
  • Sizes for inline pieces are available, so there's no gap to document there. The limits: bytes are known only once the barrier passes, and a stored piece not yet re-located after a head restart is counted as unsized.
  • The core head fix above.
  • The barrier can't see a loss whose error the driver hasn't read yet when it passes. That loss turns up after the barrier and fails the flow.

🤖 Generated with Claude Code

https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV

A loss before a Partition's barrier reads the input again: a partition
task's own, or a piece's, found when the barrier checks every piece. The
rerun releases every piece of the attempt. A loss after the barrier fails
the flow, naming the operator and the partition. FlowStats gains each
partition's bytes, counted at the barrier from Client.size_of.

A restarted head adopting a re-sent TaskMany now keeps all of its
results, not only the first (found by the head-restart gate).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycsyUqdnuDeZrYc3z6wV
@winding-lines
winding-lines merged commit e61e23a into main Nov 29, 2026
12 checks passed
@winding-lines
winding-lines deleted the flow-partition-loss branch November 29, 2026 14:39
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