Transient service discovery inconsistencies after Consul snapshot restore
0 reputation · 24 Mar 2020, 08:32 UTC
0 reputation · 24 Mar 2020, 08:32 UTC
After a Consul snapshot restore, service discovery watchers sometimes return outdated or missing entries for a short period before the cluster reconciles. The goal is to understand why this transient inconsistency occurs and what factors influence its duration.
The restore operation replaces the KV store, catalog, prepared queries, sessions and ACLs but does not rebuild the Raft log. Consequently, stale tombstone entries remain in the log until the next gossip round, allowing watchers to observe mismatched state until the cluster converges.
A Consul snapshot restore overwrites the state machine — KV store, catalog, prepared queries, sessions, and ACLs — but it does not reset the Raft log indices or the Serf gossip membership layer. The restored catalog may immediately conflict with the health-check status and node metadata that agents are still gossiping. Until the gossip protocol reconciles and health checks renew, watchers can observe missing or outdated service entries.
Confirmed: The inconsistency window is bounded by the gossip convergence time and the health-check renewal interval. In a typical LAN cluster with default settings (serf_lan_gossip_interval = 200 ms, health-check TTL often 10–30 s), full reconciliation usually completes within a few seconds to under a minute.
Likely explanation: Tombstones (deregistration markers) linger in the Raft log until the next gossip round pushes the restored catalog to all agents and agents re-evaluate their local health state against the server. If a node’s health check has a long TTL, its stale “healthy” status can mask the restored “deregistered” state until the check expires or is manually refreshed.
raft and serf messages during and after restore. Lines such as memberlist: ... or catalog: deregistering service ... indicate reconciliation activity.consul monitor -type=checks -type=services immediately after restore. A burst of ServiceDeregistered followed by ServiceRegistered events signals the convergence wave.consul catalog nodes and consul members side by side. Discrepancies in node counts or service lists pinpoint the inconsistency window.serf_lan_gossip_interval (default 200 ms) — lowering it accelerates gossip but increases CPU and network load on every agent.Caution: Aggressive gossip tuning can destabilize large clusters. Test any interval changes in staging before applying to production.
What are your current serf_lan_gossip_interval and the typical health-check TTL/interval for the affected services? If they are already at aggressive values, further tuning yields diminishing returns and the focus should shift to operational practices (e.g., scheduling restores during low-traffic windows, using consul snapshot save with -stale for faster but potentially inconsistent backups).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.