When a single agent has to work many conversations across several campaigns,
the hard part stops being any one conversation and becomes scheduling: who gets
contacted, when, fairly, without bursting a provider or starving a campaign.
This case investigates a leased queue and a passive release gate as a way to
make those decisions explicit.
A periodic task took a global lock and tried to dispatch eligible subjects
across all active campaigns. It was serial, throttled, and restarted from the
front each run. Operators also released campaigns in waves manually — splitting
a file and uploading batches.
Starvation. A large campaign's tail could delay newer campaigns behind
the same global lock.
Orphaned locks. A worker could be killed before it released the global
lock, leaving dispatch blocked.
Manual waves. Pacing a rollout meant an operator hand-splitting files and
uploading batches — slow, error-prone, and invisible to the system.
All three problems came from putting scheduling state inside a long-running
process. Fairness, ownership and release timing needed to become explicit data
that multiple short-lived workers could coordinate safely.
Instead of doing the work inside a long, globally locked request, the periodic
task could enqueue eligible subjects idempotently and return. A separate
worker could lease rows with SELECT … FOR UPDATE SKIP LOCKED, respect a rate
limit per sender, send, and record the outcome. Short-lived reservations
make ownership explicit, while per-sender limits provide a basis for fairness.
Leased dispatch queue
A short request enqueues; a separate worker could drain under a per-sender rate limit with explicit ownership.
Wave rollout could become a property of the data instead of an operator chore.
On ingest, each subject gets a release_at timestamp; the eligibility query
would gate on release_at <= now. As the clock advances, subjects become
eligible without a job flipping state.
Passive wave release
Release can be evaluated in the query, with eligibility expressed as data.
Scheduling problems can masquerade as performance problems. This design changes
the shape: short requests, a leased queue, per-sender fairness, and release
expressed as data the system can evaluate at read time.