fix: make a double ctrl-c actually stop in-flight copies - #209
Open
alejandrodnm wants to merge 1 commit into
Open
fix: make a double ctrl-c actually stop in-flight copies#209alejandrodnm wants to merge 1 commit into
alejandrodnm wants to merge 1 commit into
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A hard shutdown did not stop anything.
Worker::runselected between the hard-shutdown token andtokio::spawn(run_inner(..)), and when the hard-shutdown branch won theJoinHandlewas 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
AbortHandlebefore the select and aborting on hard shutdown restores the behaviourdocs/design/backfill-tool.mddescribes — two ctrl-c's force terminate, rolling back open transactions. It also removes thedouble_ctrl_c_stops_hardCI 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