fix(scanqueue): fence stale scan workers - #802
Open
Quick104 wants to merge 1 commit into
Open
Conversation
|
Warning Review limit reachedNext included review available in 57 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 94 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
Comment |
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.
Problem
Related issue: N/A — audit-validated distributed correctness fix
Scan workers owned a run only by its row ID and
runningstatus. Stale-run maintenance reused that same row when requeueing, so worker A could lose its heartbeat, worker B could claim the requeued run, and A could later resume and write progress or a terminal status into B's work.The finding was independently reproduced against fresh
origin/mainat8164fd594b9fdd8c1944bb0b6251f2d00e4a24ca. No existing issue or PR matched the defect.Approach
scan.startedor beginning ingestion. Local cancellation is registered first, and local lease loss cancels guarded scanner and metadata contexts synchronously.running, rejects tokenless legacy claims, and rejects legacy in-place requeues.The protocol invariant is: a worker may mutate a run or perform scan-owned ingestion only while
(run_id, claim_token)is the current durable claim. Losing that ownership cancels local work; retry creates a new run ID.Validation
Repository gate:
Focused and race checks on isolated dev-builder sandbox
audit-scan-lease:Migration lifecycle against pre-existing accepted, running, and completed rows:
The exact candidate was built and deployed in
audit-scan-lease. Controllerdoctorreported the application and Redis containers healthy, the database query successful,/api/v1/healthstatusok, and both API and frontend reachable. The synthetic A/B lifecycle passed against the sandbox Postgres; scan claims do not store ownership state in Redis.Two exploratory configurations were not used as gates: exporting one
SILO_TEST_DATABASE_URLto every package inmake test-gocaused unrelated parallel database suites to mutate the same schema, and running the entire metadata package under-raceexposed a pre-existing test-fake race plus unrelated schema interference. The supported full suite passed without that global opt-in; the changed Postgres packages and the new metadata guard test passed separately under-raceas shown above.No screenshots: this changes backend orchestration and schema only.
Risks
claim_token; upgraded code reads that column.Independent read-only review covered stale-worker bypasses, mixed-version migration safety, requeue/retry behavior, cancellation races, derived contexts, completion boundaries, and after-commit side effects. It found and drove fixes for the rollout barrier, old-maintenance bypass, cancel/requeue race, durable startup fencing, derived-context guard propagation, completion-boundary classification, and startup cancellation registration. The final review reported no actionable findings.
AI Disclosure
Checklist