Make background outbox claims lease-safe during slow delivery #479

Closed
opened 2026-08-10 11:09:28 +00:00 by timmy · 0 comments
Owner

Problem

Background sync claims up to 70 records for a fixed 30-second lease before three workers process them. Slow requests and screenshot stages can outlive that lease, allowing a foreground tab or another sync event to reclaim in-flight work.

User impact

Large offline queues can create duplicate upload traffic, idempotency contention, and misleading attention states even though each logical operation is retry-safe.

Acceptance criteria

  • Claim records just in time as worker capacity becomes available.
  • Give each drain a unique claim token and renew ownership before every network stage.
  • Complete, release, and fail only when the caller still owns the token.
  • Preserve crash recovery, unchanged idempotency keys, three-worker concurrency, finite admission, and lane fairness.
  • Behavioral tests reproduce lease expiry/takeover and stale-owner fencing.

Evidence / non-duplication

frontend/background-issue-sync.js currently uses a 30s claim and claims an entire batch before processing. Historical #297 added bounded concurrent draining, #305 request timeouts, #242 tab coordination, and #471 idempotent uploads; none adds lease renewal or ownership fencing.

## Problem Background sync claims up to 70 records for a fixed 30-second lease before three workers process them. Slow requests and screenshot stages can outlive that lease, allowing a foreground tab or another sync event to reclaim in-flight work. ## User impact Large offline queues can create duplicate upload traffic, idempotency contention, and misleading attention states even though each logical operation is retry-safe. ## Acceptance criteria - Claim records just in time as worker capacity becomes available. - Give each drain a unique claim token and renew ownership before every network stage. - Complete, release, and fail only when the caller still owns the token. - Preserve crash recovery, unchanged idempotency keys, three-worker concurrency, finite admission, and lane fairness. - Behavioral tests reproduce lease expiry/takeover and stale-owner fencing. ## Evidence / non-duplication `frontend/background-issue-sync.js` currently uses a 30s claim and claims an entire batch before processing. Historical #297 added bounded concurrent draining, #305 request timeouts, #242 tab coordination, and #471 idempotent uploads; none adds lease renewal or ownership fencing.
timmy self-assigned this 2026-08-10 11:09:28 +00:00
timmy closed this issue 2026-08-10 11:23:40 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stackchain/stackchain-dashboard#479
No description provided.