Prepared query results inconsistent after Consul snapshot restore
0 reputation · 08 Oct 2021, 20:20 UTC
0 reputation · 08 Oct 2021, 20:20 UTC
Consul does not maintain a separate in-memory index for prepared queries that requires rebuilding after a snapshot restore. Prepared queries are stored as objects in the servers' Raft-replicated state store (memdb) and are evaluated against that store at execution time. A successful snapshot restore replaces the entire Raft state, so prepared query definitions and the catalog data they query are immediately consistent with the snapshot contents.
If query results look outdated after restore, the cause is almost always client-side or agent-side caching, not a server-side index problem:
No agent restart or manual rebuild is needed. To bypass caches and verify the server-side state:
curl "http://localhost:8500/v1/query//execute?consistent=true&cached=false"systemd-resolve --flush-caches or dscacheutil -flushcache).curl "http://localhost:8500/v1/catalog/service/"
curl "http://localhost:8500/v1/health/service/"consul snapshot inspect <file> — confirm it contains the expected prepared query definitions.consul operator raft list-peers and consul info on each server. Verify a single leader exists and all servers report matching raft.applied_index values.There is no prepared-query index to rebuild. The restored Raft state is the source of truth. If results look wrong, the cluster has not fully converged or a cache layer is serving stale data. Bypass caches, verify Raft convergence, and re-run the query with consistent=true&cached=false to confirm correctness.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.