Skip to content

fix: make a double ctrl-c actually stop in-flight copies - #209

Open
alejandrodnm wants to merge 1 commit into
mainfrom
adn/abort-copies-on-hard-shutdown
Open

fix: make a double ctrl-c actually stop in-flight copies#209
alejandrodnm wants to merge 1 commit into
mainfrom
adn/abort-copies-on-hard-shutdown

Conversation

@alejandrodnm

Copy link
Copy Markdown
Contributor

A hard shutdown did not stop anything. Worker::run selected between the hard-shutdown token and tokio::spawn(run_inner(..)), and when the hard-shutdown branch won the JoinHandle was dropped — which detaches a tokio task rather than stopping it. The in-progress copy kept streaming, committed its transaction and marked its task complete, all after the tool had printed "Terminating immediately." and reported "Copied 0B from 0 chunks". So a force-terminated run could tell the user nothing was copied while a chunk had in fact been copied and recorded as done.

Taking an AbortHandle before the select and aborting on hard shutdown restores the behaviour docs/design/backfill-tool.md describes — two ctrl-c's force terminate, rolling back open transactions. It also removes the double_ctrl_c_stops_hard CI flake: whether the detached copy's completion line escaped before the process exited was a pure race, and slower runners lose it (run 33012008125). The test is no longer gated off macOS either, where a stale comment blamed the platform for what was this bug.

https://claude.ai/code/session_01MphA7yobURuWfDNk8RdY83

`Worker::run` selected between the hard-shutdown token and
`tokio::spawn(run_inner(..))`. When the hard-shutdown branch won, the
`JoinHandle` was dropped, which detaches the task instead of stopping
it: the in-progress copy kept streaming, committed its transaction and
marked the task complete after we'd already printed "Terminating
immediately." and "Copied 0B from 0 chunks".

Take an `AbortHandle` before the select and abort the inner task on hard
shutdown. This also un-gates `double_ctrl_c_stops_hard` on macOS, where
the stale comment blamed the platform for what was this bug, and removes
the CI flake: whether the detached copy's completion line escaped before
the process exited was a pure race, lost on slower runners.

Claude-Session: https://claude.ai/code/session_01MphA7yobURuWfDNk8RdY83
@alejandrodnm
alejandrodnm requested a review from a team as a code owner August 27, 2026 10: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