Skip to content

Relay fix hard-stop: real pause/resume/stop for SENDING campaigns - #76

Open
alexeygrigorev wants to merge 1 commit into
mainfrom
relay-fix-hard-stop
Open

alexeygrigorev wants to merge 1 commit into
mainfrom
relay-fix-hard-stop

Conversation

@alexeygrigorev

Copy link
Copy Markdown
Member

Lock-free halt flag (Campaign.send_halted_at + send_halt_reason, migration 0049) set by plain UPDATE; sender checks it before every SES call and in the drain loop. Pause = resumable halt, resume re-enqueues remaining PENDING only, stop = permanent CANCELLED with sent rows kept. API POST pause/resume/stop + UI buttons for queued/sending campaigns. Retryable SES throttling requeues remaining PENDING with run_after backoff (bounded, loud) instead of failing the batch.

Acceptance tests: mailing/tests/test_campaign_hard_stop.py (10 tests: zero SES calls after ack, 1-call stop latency, resume no-duplicates, no-lock code proof, API + UI incl. visible errors, throttle requeue + exhaustion). Neighbouring suites green locally (204 passed).

@alexeygrigorev
alexeygrigorev force-pushed the relay-fix-hard-stop branch 4 times, most recently from c362b1b to 8e01ae4 Compare November 9, 2026 14:03
Lock-free halt flag (Campaign.send_halted_at + send_halt_reason) set by a
plain UPDATE so pause/stop never wait behind senders' FOR SHARE locks. The
sender reads the flag with a plain SELECT before every SES call and in the
drain loop; once seen, no further SES calls happen in that batch and
remaining PENDING recipients are left untouched and resumable.

Pause keeps the campaign SENDING and is resumable (resume clears the flag
and re-enqueues batches for remaining PENDING only); stop moves it to
CANCELLED permanently with sent rows kept. New API endpoints
POST /api/campaigns/<key>/{pause,resume,stop} plus operator UI buttons for
queued/sending campaigns, with visible errors on failure.

Retryable SES throttling no longer fails the batch at the task layer: the
remaining PENDING recipients of the batch are requeued as a new task with
run_after backoff and bounded attempts (RELAY_CAMPAIGN_THROTTLE_*),
logged loudly; exhaustion re-raises.

This branch has not been deployed

No deployments
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.

1 participant