Repository navigation
Conversation
…queueing it again
|
@deanrie is attempting to deploy a commit to the Anysphere Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
What
recover-stuck-scansresets a stalescanningrow topendingwithout enqueueing it again. Stalependingrows are enqueued as before.Why
The drain archives a queue message only after
runPluginScanhas written a terminal status:applyVerdicton success,markScanFailedon fatal, retryable andMAX_ATTEMPTSpaths,applyBlockedShortCircuitfor blocked plugins. The one way a row stays atscanningpast the threshold is a worker that died mid-run (800 s cap, OOM, platform kill). That worker never archived its message, so the message comes back when the 900 s visibility timeout expires and the minute drain re-reads it.The cron already handles that row by resetting it to
pending, and then also callsenqueuePluginScan. That puts a second message for the same plugin intoplugin_scans: two fullrunPluginScancalls (two billable agent runs) and twoapplyVerdictwrites racing. WithVT_SECONDS(900) equal toSTALE_AFTER_MS(15 min) the returning message and the cron's duplicate arrive within the same minute.pendingis different: insert, update and re-scan all catch anenqueuePluginScanfailure and leave the row atpendingfor this cron to pick up (see the comment ininsert.ts), so a stalependingrow may have no message at all and re-enqueueing it is the cron's job.Change
One file. A stale
scanningrow is reset and reported asaction: "reset"; a stalependingrow is enqueued and reported asaction: "enqueued". The response adds aresetcount next toretriedandfailed. If a reset row's message really is gone (a row from before the queue existed), the next tick sees it as stalependingand enqueues it then, so recovery moves by one tick rather than being lost.Checked
route.tsand a stub Supabase + queue: onmainone tick over a 16 min oldscanningrow and a 16 min oldpendingrow enqueues both; with this change it resets the first and enqueues the second, and a second tick 16 min later enqueues the reset row if nothing drained it. Freshpending/scanning,errorandsaferows untouched in both.tscreports the same single pre-existing error inscan.ts(platformonAgentOptions) onmainand on this branch.git merge-treeclean againstmainand against plugins: let owners re-run the security scan from the listing menu #458, fix(scan): cap what a repository archive unpacks to before it reaches tmpfs #469, fix(admin): judge a stuck scan by updated_at, like the recovery cron and the rescan tool #470, fix(github-plugin): encode repo paths in raw.githubusercontent.com URLs #472, fix(moderation): refuse a re-scan while one is queued or running, from every entry point #473.Related: #473 removes the same duplicate from the admin re-scan buttons. Not covered here: a worker killed between
applyVerdictandarchivePluginScanstill re-runs once when its message returns, and a stalependingrow whose message is merely waiting in a backlog still gets a duplicate; both need either a scan start timestamp on the row or queue introspection.