Skip to content

fix(npmjs): follower cannot recover from large scan backlogs - #1938

Merged
cdklabs-automation merged 2 commits into
mainfrom
mrgrain/fix/npmjs/scan-backlog-recovery
Sep 24, 2026
Merged

cdklabs-automation merged 2 commits into
mainfrom
mrgrain/fix/npmjs/scan-backlog-recovery

Conversation

@mrgrain

@mrgrain mrgrain commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

After deploying #1937 our environment is still stuck. The state file hadn't been saved for 24 hours because of the crashes, so the follower has a backlog of roughly 250k entries without receipts. That is more work than fits into one execution. Runs hit the Lambda timeout, and on a timeout Lambda kills the process without running the finally block. So the state was never saved, and the next run started over with the same backlog.

We can fix this:

The scan now processes entries in chunks of 1,000 and saves the state (receipts, checkpoints, laggy packuments, known versions) after every chunk. If a run is killed, only the current chunk is lost. Progress is kept between runs and the backlog shrinks until it's gone. The time budget is now also checked between chunks.

Previously these checkpoints were only run after a full page, which can be up to 10k changes. During a catch-up a most entries will be without receipts, and processing them can take longer than the whole execution.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

After an outage or crash period, the unreceipted backlog can be larger
than what fits into a single execution. Runs then die at the Lambda
timeout, which is a hard kill: the end-of-run state save never
executes, so every run restarts the same backlog from scratch and the
follower never recovers. Gamma live-locked this way for a day with a
24h backlog.

The scan now processes unreceipted entries in chunks of 1,000 and
persists the state (receipts, checkpoints, laggy packuments, known
versions) after every chunk. The time budget is re-checked between
chunks, so runs exit cleanly before the timeout, and even a hard kill
only loses the current chunk. Each run banks its progress and the
backlog drains across runs.
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@cdklabs-automation
cdklabs-automation added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit 5a7a78c Sep 24, 2026
12 checks passed
@cdklabs-automation
cdklabs-automation deleted the mrgrain/fix/npmjs/scan-backlog-recovery branch September 24, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants