Repository navigation
Phase 3 (D): bounded auto-retry for failed archives - #743
Merged
neuromechanist merged 2 commits intoJun 11, 2026
Merged
neuromechanist merged 2 commits into
neuromechanist merged 2 commits into
Conversation
Contributor
Author
|
Sonnet /review-pr addressed:
|
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR743Version: 🤖 Updated on each push. |
neuromechanist
merged commit Jun 11, 2026
51f8f16
into
feature/issue-736-epic-publish-robustness
1 check passed
This was referenced Jun 11, 2026
This branch was previously 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.
Summary
Phase 3 (D) of epic #736. Make failed archive generation self-healing.
/webhooks/archive-readyrecordedarchive_status='failed'but nothing re-dispatched, so a failed archive sat failed until a human noticed (the nm000111 incident). Adds a bounded auto-retry via two mechanisms sharing one counter and cap:failedarchive-ready callback, re-dispatchtriggerArchiveGenerationright away while under the cap (fast self-heal during a publish).archiveRetrySweepin the scheduled handler re-dispatches still-failed datasets whose last attempt is stale (>6h) — catching a chain that broke because a callback was lost.archive_retry_count(migration 0040) counts retry dispatches and is incremented at the moment a retry is dispatched, so the webhook and sweep never double-count one attempt. Capped atMAX_ARCHIVE_RETRIES = 3(kept small: a retry re-downloads every available annex blob before detecting a still-missing one, so each attempt is costly for large datasets) and reset to 0 onready. Noforceflag needed — Phase 2 deletes the partial on failure.Zarr is deliberately not auto-retried (per the Phase 3 decision): conversion is owned by the hourly Hallu cron (autodispatch is off), and many zarr failures are the mixed-rate EDF/BDF reader bug (#737) a re-dispatch wouldn't fix. The zarr-ready failed path still records
zarr_status='failed'for dashboard visibility; a comment documents the intent so a future reader doesn't add a redispatch.Closes #740
Part of epic #736
Files
backend/src/db/migrations/0040_dataset_archive_retry_count.sql—archive_retry_count INTEGER NOT NULL DEFAULT 0.backend/src/services/archive-retry.ts(new) —decideArchiveRetry(pure),versionFromDoi(pure),ARCHIVE_RETRY_SWEEP_QUERY,archiveRetrySweep,MAX_ARCHIVE_RETRIES. ReusestriggerArchiveGeneration+getDatasetsToken.backend/src/routes/webhooks.ts— archive-ready handler: reset count onready; onfailed, read count, decide, persistnextCount, and re-dispatch under the cap (best-effort, never 500s the callback). Zarr-ready comment.backend/src/index.ts—ctx.waitUntil(archiveRetrySweep(env))in the daily scheduled handler.Test plan
bun test backend/test/archive-retry.test.ts— 12 tests, real in-memory SQLite (all migrations applied), no mocks:decideArchiveRetry: ready resets; failed+no-version no-retry (count untouched); failed under cap retries+increments; failed at/above cap gives up; a full failure chain converges to exactlyMAX_ARCHIVE_RETRIESdispatches then stops.versionFromDoi: version DOI -> bare version; concept/malformed/empty -> null.archive_retry_countdefaults 0; ready-callback UPDATE resets to 0.ARCHIVE_RETRY_SWEEP_QUERY: selects failed+versioned+under-cap+stale (and NULL-checked) rows; excludes ready, no-version, at-cap, and recently-checked rows.Typecheck (
tsc --noEmit) clean; Biome clean; migration-chain tests (archive-status, access-requests) still green with 0040 applied.Deferred to epic finalization: the live archive-ready -> retry -> GitHub dispatch and the cron sweep exercise when the epic deploys to dev/prod (auto-deploy +
d1 migrations apply). Deploying unmerged phase code to the shared dev Worker now would be disruptive; the glue over the unit-tested logic is thin.