When a capture cannot release its TQ view, the error that says "stop checkpointing" gets lost

PR #5241 ยท permalinks at head 96c48d50, removed code at base 68bd259c

Before
The TQ capture ran last and was awaited on its own, so a CheckpointReleaseError from it always reached the caller and stopped checkpointing.
This PR
Runs the capture beside three other phases in _run_capture_phases, which raises some other error first in two cases.
Status
Open โ€” not fixed in this PR. Raised as review comment C1, with a fix and two regression tests.

Two pages on this PR. This one: an error the new phase runner loses.

A TQ capture copies TransferQueue's state into memory while the barrier is held, so the slow disk write can happen after rollouts resume. The copy (the "view") stays in the storage actors' memory until it is written and released.

A TQ capture keeps a view on the storage actors. If the code cannot confirm the view was released, it raises CheckpointReleaseError: "storage actors may still retain it, so stop checkpointing". The snapshot pump retries an OSError or a timeout, and stops only on other errors. So which error comes out of the phase runner decides whether a possibly held view triggers another snapshot.

Two ways the release error is lost

A ยท two phases fail at once replay_inventory: OSError recovery_state: ok staging_inventory: ok tq_capture: ReleaseError failed[0].result() first in dict order wins; tq_capture is always last raises OSError โ†’ "io_error" โ†’ retried Next snapshot starts; a view may still be held. B ยท the snapshot is cancelled mid-capture outer task cancelled โ†’ phases cancelled capture_checkpoint: late view, release fails โ†’ task ends with CheckpointReleaseError _release_captured_view: task raised โ†’ skip bare raise โ†’ CancelledError Caller sees a plain cancel; no log line names the held view. At base the capture was awaited directly, so this raised CheckpointReleaseError. The review's test passes at base and fails at head. failed retryable fine

Case A needs two failures at once, for example a full disk while the capture's own cleanup fails. It could not happen before, because a failing check meant the capture never started. Case B is a plain regression. Trainer checkpoints go through the same runner but are not retried, so case A matters less there.

๐Ÿ”ด review comment C1 โ€” snapshots.py:475

The fix, as pseudocode (proposed, not in the PR)

Where the fix lands: RL only, one function. _run_capture_phases in snapshots.py, plus two tests in test_checkpointing.py. Nothing below is implemented.

# controller event loop, barrier held
tasks = {name: create_task(phase) for name, phase in phases}
def raise_release_error(done):                # "stop checkpointing" beats any other error
    for t in done:
        if t raised CheckpointReleaseError: raise it
try:
    await wait(tasks)                         # all phases run to the end
except CancelledError:
    cancel all; wait until all are done
    raise_release_error(tasks)               # case B
    release the capture's view if it has one
    raise
failed = [t for t in tasks if t failed]
if failed:
    raise_release_error(failed)              # case A
    release the capture's view if it has one
    failed[0].result()                        # first phase error, as today

Real code: _run_capture_phases, _release_captured_view.

So what. A held storage view keeps memory on the TQ storage actors until released. CheckpointReleaseError exists so a run stops instead of piling up more views. In both cases above it is replaced by an error that either retries or looks like a normal shutdown. The fix is a few lines and keeps everything else the PR does.