A leader election protocol needs to elect exactly one leader even across network partitions. Doing it yourself in DB rows is fragile (split brain, two leaders, lost lock on failure). etcd/ZK provide distributed locks with TTL + health-check. Most schedulers (Kubernetes, Nomad) build on this primitive.
Lease with TTL: whoever holds the lease is the leader.
Watch event: clients wake up when the leader changes.
Etcd/Consul/ZK for the primitive; bespoke implementations are risky.
candidates attempt lease
one wins -> leader
heartbeat keeps lease alive
on heartbeat failure -> lease expires -> other candidate wins
Use a distributed primitive (etcd) for leader election. Don’t invent it on top of row locks.