Skip to content

fix(sync): release backfill inflight slot on terminal status poll after stale self-heal - #18906

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/sync-stale-backfill-slot-release
Sep 25, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/sync-stale-backfill-slot-release

Conversation

@kduailabs

@kduailabs kduailabs commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #18905

Summary

  • When a backfill sync job stalls in processing (or unstarted queued cloud_tasks dispatch), get_sync_job(job_id) self-heals job[status] = failed on read and writes the pending dead-letter record before returning to get_sync_job_status.
  • Because job[status] is already failed when get_sync_job returns, the subsequent is_sync_job_stale(job) branch in get_sync_job_status (backend/routers/sync.py:1457) evaluates to False and never reaches release_backfill_slot(uid, job_id), leaving sync_backfill:inflight:{uid} locked to the dead job_id for its 48-hour TTL (BACKFILL_SLOT_TTL_SECONDS) and blocking client WAL retry uploads with HTTP 429 (backfill_paced).
  • Call release_backfill_slot(uid, job_id) in get_sync_job_status once the durable dead-letter record (pending or dead_letter) is verified for a terminal (failed / partial_failure) backfill job (leaving the slot intact if the dead-letter check fails closed with 503).
  • Add unit tests test_poll_stale_self_healed_backfill_releases_inflight_slot and test_poll_failed_backfill_without_ledger_does_not_release_slot in backend/tests/unit/test_sync_dead_letters.py.

Product invariants affected

none

Failure-Class: none

Review in cubic

…er stale self-heal

When a backfill sync job goes stale in 'processing' (or unstarted 'queued'
cloud_tasks dispatch), get_sync_job(job_id) self-heals the job to 'failed'
on read and records the pending dead-letter entry. Because job['status'] is
already 'failed' when get_sync_job returns to get_sync_job_status, the
subsequent is_sync_job_stale(job) branch in get_sync_job_status evaluates
to False and never reaches release_backfill_slot(uid, job_id).

Once get_sync_job_status verifies the durable dead-letter record for a
terminal ('failed' or 'partial_failure') backfill job, release the per-UID
backfill slot via release_backfill_slot(uid, job_id) (which uses an atomic
Lua compare-and-delete keyed to job_id) so client retries are not blocked
for 48h by HTTP 429 backfill_paced.

Failure-Class: none

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped backfill-slot release fix, root cause stated with line refs, tests added, CI green. Confidence 5/5.

@kodjima33
kodjima33 merged commit 899685e into BasedHardware:main Sep 25, 2026
44 checks passed
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.

[Bounty Proposal] Release per-UID backfill in-flight slot when stale backfill jobs self-heal on status poll

2 participants