feat: leader election for subscriptions and automations — Closes #26 #165
No reviewers
Labels
No labels
bug
documentation
enhancement
investigation
nice-to-have
performance
production-ready
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ash/eskit!165
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/leader-election-26"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Leader election via Postgres advisory locks for multi-node deployments.
One line to enable:
LeaderLock: pgstore.NewPgLockRegistry(pool)How It Works
Start()→LeaderLock.Acquire(ctx, lockID)— blocks until acquireddefer release()→ instant handoff (2ms)Critical Fix: Automation Checkpoint Safety
Previously, the subscription auto-checkpointed after the handler queued work to the TodoList. If the process crashed before execution, events were permanently lost.
Fix: Automation disables auto-checkpoint (
AtomicCheckpoint=true) and saves checkpoint itself — only afterexecutePending()succeeds. Crash before execute → events replay → side effects run.Two Patterns
Simple (subscription + LeaderLock): trigger → execute inline in handler → checkpoint. For emails, webhooks, simple side effects.
Complex (automation + LeaderLock): trigger → TodoList → deferred execute → checkpoint. For completion tracking, batching, retry with backoff.
Benchmarks (Postgres, AMD EPYC)
Tests
Closes #26
feat: leader election + competing consumers for automations & subscriptionsto feat: leader election for subscriptions and automations — Closes #26