500 Days Without Compaction: How etcd Hit 8 GiB NOSPACE & Broke DB HA
#etcd#MVCC#Quorum#PostgreSQL HA
The Outage
A 5-node etcd cluster backing PostgreSQL high-availability election suddenly rejected all writes with mvcc: database space exceeded (NOSPACE). Thirty-two seconds later, the /database/master_ip key vanished and the entire management layer lost database connectivity.
Reconstructing the 500-Day Failure Chain
Log forensics revealed three compounding issues—none of which alone would have caused a total outage:
- 500 days without compaction: The cluster ran without
--auto-compaction-retention. Meanwhile, replica heartbeats created fresh leases and rewrote keys every 2 seconds (~160,000 writes/day), accumulating 77.33 million MVCC revisions until the backend hit its 8 GiB ceiling. - Silent quorum erosion (3/5 online): Once the database crossed 4.5 GB, member startup exceeded systemd’s default 90-second timeout. One node entered a restart loop (227,000+ restarts); another failed months earlier and was never noticed due to missing etcd monitoring.
- Serialized retries killed the 10s lease: Under
NOSPACE, lease renewals still work—only new writes fail. However, the leader ran replica registration and master heartbeat serially in the same loop. Retrying failed registrations against the half-dead member stalled each cycle past the 10-second TTL, expiringmaster_ip, which could then never be written back.
Quorum-Safe Recovery Runbook
With only 3 of 5 members alive and every DB at 8 GiB, restarting any live node would lose quorum immediately. The safe recovery sequence:
- Relax systemd
TimeoutStartSecon live nodes first (without restarting etcd). - Take a full etcd snapshot backup before touching history.
- Compact to the latest revision (retaining the 46 live keys), then run
etcdctl defragstrictly one member at a time. - Disarm the
NOSPACEalarm, restore the two offline members, and enable automatic compaction plus DB-size alerting.
Enjoyed this note or seen a similar bug?
Feel free to drop a line—always glad to exchange ideas with fellow engineers.