You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bounty Proposal] Release per-UID backfill in-flight slot when stale backfill jobs self-heal on status poll #18905
With SYNC_BACKFILL_INFLIGHT_LIMIT enabled by default (#18855), each user is limited to one in-flight backfill sync job via Redis key sync_backfill:inflight:{uid} (BACKFILL_SLOT_TTL_SECONDS = 172800 / 48 hours).
When a backfill sync job stalls in processing (>600s without worker heartbeat) or in queuedcloud_tasks dispatch (>1800s without start), polling GET /v2/sync-local-files/{job_id} (get_sync_job_status in backend/routers/sync.py) calls job = get_sync_job(job_id) at line 1439:
get_sync_job(job_id) (backend/database/sync_jobs.py:229-241) detects is_sync_job_stale(job) == True, marks job["status"] = "failed", records the pending dead-letter record (_backfill_dead_letter_pending), and persists job to Redis.
When get_sync_job returns job (now status == "failed") to get_sync_job_status, the subsequent if ... and is_sync_job_stale(job) and job.get("dispatch_mode") == "cloud_tasks": branch at line 1457 evaluates to False (since is_sync_job_stale returns False when status not in ("processing", "queued")), skipping release_backfill_slot(uid, job_id) at line 1498.
get_sync_job_status verifies the durable dead-letter record at lines 1540-1560 and returns status: "failed" to the client (whose WAL terminal policy is retry), while sync_backfill:inflight:{uid} remains locked to the dead job_id for up to 48 hours, rejecting subsequent historical recovery uploads with HTTP 429 (backfill_paced).
Proposed Fix
In get_sync_job_status (backend/routers/sync.py), once the durable dead-letter record (status in ("pending", "dead_letter")) is verified for a terminal (failed or partial_failure) backfill job, invoke release_backfill_slot(uid, job_id) (which uses an atomic Redis Lua compare-and-delete keyed to job_id).
Activity