Let the callback say whether it still has work - #189
Merged
Conversation
The settle loop I added in #183 never ran. It asked the tracker whether anything was pending through a separate call, and the tracker is an async actor, so that call can be answered before the callback it was meant to observe has started. Measured on an actor of the same shape, submitting callback, callback, query and recording execution order: ['query-ran', 'callback-a-start', 'callback-a-end', 'callback-b-start', 'callback-b-end'] The query runs first, sees an empty pending list, reports no work, and the loop exits without retrying anything. The last batch is stranded exactly as it was before, which is why builds still failed roughly one run in eight, always with an empty dataframe after the full 120s wait. Have the callback return whether it still holds tasks instead. The caller waits on that same call, so there is nothing left to race: the answer describes work the callback has already done. Still only reproduces under CI timing; the suite passes here either way. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Contributor
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.
Builds were still failing intermittently — roughly one run in eight. They were easy to miss because the failures were hidden behind re-runs:
gh run listreports the final conclusion, so a run that failed on attempt 1 and passed on attempt 2 shows as green. Checkingrun_attemptsurfaced run 32660537412, which failed on its first attempt with the same symptom as before:Tracker created at 19:13:56, assertion at 19:15:58 — the full 120s wait, so nothing ever arrived.
Why #183 didn't fix it
The settle loop I added there never ran. It asked the tracker whether anything was pending via a separate
has_pending_tasks()call.AsyncMetadataTrackeris an async actor, so that query can be answered before the callback it was meant to observe has even started.Measured on an actor of the same shape — submitting
callback,callback, then the query from one caller, recording execution order:The query runs first. It sees an empty pending list, reports no work, and the loop exits immediately without retrying anything — leaving the last batch stranded exactly as before. The probe also shows callbacks are serialized, so there was no data race on
pending_tasks; ordering was the whole problem.The fix
callbacknow returns whether it still holds tasks, and the caller waits on that same call. There is nothing left to race: the answer describes work the callback has already finished doing.has_pending_tasks()is gone.Verification
test_callback_reports_tasks_the_gcs_has_not_publishedpins the contract. Dropping thereturnreproduces the regression:53 tests pass locally; lint and checks clean.
Same caveat as #183: this only reproduces under CI timing — the suite passes on macOS with or without the change — so CI is the real judge. Given the ~1-in-8 rate, a couple of green runs would not be meaningful; I'll re-run this branch several times before marking it ready.