Repository navigation
fix(security-sync): resume owner progress on lease takeover - #7047
Conversation
A run that took over an owner lease replaced the saved checkpoint with an empty skeleton, so every takeover restarted at the first repository and large owners rescanned the same prefix without ever completing. The 7-day lease TTL also locked an owner for a week whenever its chain died. A taking-over run now adopts the previous checkpoint (completed repos and counters, without the chunk fence or no-progress count), and the lease TTL drops to 20 minutes, which still outlives the 15-minute consumer limit.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryReviewed the lease-takeover change in Files Reviewed (2 files)
Notes (not blocking): adoption carries the prior run's Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
Summary
Some large owners have stopped completing a Security Agent sync. Each run covers the same first ~10 repositories and never reaches the rest, so
last_synced_atnever advances. After #7023, an owner can also be locked out for up to 7 days.Two causes in
claimOwnerSyncLease:sync_runwith an empty skeleton. Whenever another run's message slipped in between a run's chunks, the run started over at repo 0. Slow repositories in the first part used up the 8-minute budget every time.held_by_otheruntil the lease expired a week later.Fix:
sync_run(completed repos and counters) under its own run ID. It drops the oldchunkIndex, which would otherwise reject its writes, and resetsnoProgressChunks. Taking over now continues the remaining work instead of restarting, so completion always moves forward whichever chain runs.Verification
claim acquiredwithresumed: true, thenSecurity sync completed for owner, andlast_synced_atadvances.Automated (local Postgres):
security-syncunit tests 93/93, integration tests 11/11. The two new integration cases fail with the fix reverted:syncOwner: a run that died at chunk 3 having synceda, b; the next run fetches onlycand the owner completesVisual Changes
N/A
Reviewer Notes
sync_run, so stuck owners pick up where they left off, and gives any chunk that is running a 20-minute grace period:COMMAND_STALLEDwhile the queue backlog exceeds the 5-minute reconciler threshold. Repositories reporting 403 "Dependabot alerts are disabled" need the GitHub App permission on the customer side.