A sharded vector store snapshots each node on its own and keeps chunk text in a separate store; why can the restored system be inconsistent, and how do you prevent it?
answer
- snapshots taken at different moments
- a document split across shards
- dangling IDs and invisible chunks
- one cut, or replay to one point
- reconcile ID sets before serving
basics
~20 sCopies snapshotted minutes apart freeze each shard and the text store at different moments, leaving half-present documents, mixed versions and vectors with no text. Take one cut with writes paused, or record each copy's log position and replay all to one point.
solid answer
~50 sEach copy is consistent with itself but not with the others. If shard A is captured at 02:00 and shard B at 02:07, a document whose chunks span both and was re-indexed at 02:03 comes back half old, half new. If the text store was captured at 02:15, some restored vector IDs point at text deleted between 02:00 and 02:15, and text written in that window has no vector at all. I prevent it in one of two ways: pause ingestion and take every copy at a single cut, or give every write a sequence number from a durable ingest log, record each copy's position at snapshot time, and after a restore replay each copy forward to one shared target position. Either way I reconcile ID sets across shards and the text store before serving.
code
pseudocode · 9 lines# restore each copy, then bring every copy to one shared target position
target = ingest_log.last_seq()
for copy in shards + [text_store]:
restore(copy, copy.snapshot) # copy.snapshot.position = last seq applied
for entry in ingest_log.read(after = copy.snapshot.position, through = target):
if routes_to(entry.chunk_id, copy):
apply(copy, entry) # idempotent upsert, delete or access change
reconcile_ids(shards, text_store) # dangling vectors, missing vectors
open_traffic()go deeper
Remember that a sharded store's snapshot is really several snapshots, one per node, and they are only safe to restore together if they show the same moment.
Explain the defects a skewed restore causes: half-present documents, mixed versions, vectors whose text is gone, text with no vector, and access lists of different ages.
Design the fix: a paused cut or per-copy log positions with idempotent ordered replay, log retention past the snapshot interval, and an ID reconciliation before serving.
Weigh an ingestion pause against running an ordered change log for every write, and decide whether side stores belong inside the same recovery boundary as the index.
## Why per-copy snapshots disagree A sharded vector store splits its records across several nodes, each holding a **shard** of the index. Many deployments also keep chunk text, metadata or access lists in a **side store**, such as the relational database already in production, and keep only IDs and vectors in the index. Each node's snapshot is usually **internally consistent**: it captures that shard at one moment. The trouble is that the moments differ. A restored system is only correct if every copy reflects the same set of writes, a **consistent cut**. Snapshots started by separate schedules, or by one script that walks the nodes in turn, capture each copy minutes apart, and every write that landed in between is present in some copies and missing from others. ## What goes wrong | Symptom after restore | Cause | What users see | |---|---|---| | Half-present document | Its chunks span shards captured before and after it was added | Partial answers, missing context | | Mixed versions | A re-index replaced the chunk set between two shard snapshots | Old and new passages side by side, contradictions | | Dangling vector IDs | The text store was captured after chunks were deleted | Results with no text, errors or silent gaps | | Invisible text | Text written after the shard snapshots has no vector | Documents that exist but are never retrieved | | Access mismatch | Access lists in the side store and on the vectors differ in age | Wrong filtering, in either direction | Usually none of these raises an error at restore time. The restore reports success; the defects show up later as wrong answers. ## Option 1: one cut with writes paused The simplest correct approach is to make every copy capture the same state: 1. Pause ingestion and wait for in-flight writes to become durable on every shard. 2. Snapshot every shard and the side store. 3. Record the cut as one identifier on every artefact. 4. Resume ingestion. The cost is an ingestion pause for as long as the snapshots take, which is fine for a nightly job on a modest corpus and painful for a large one. Some stores offer a cluster-wide snapshot call; check whether it truly captures all shards at one logical point or simply runs per-shard snapshots in parallel. Either way, it does not cover a side store it does not own. ## Option 2: positions and replay The alternative accepts copies taken at different times and repairs them on restore: - Route every write, delete and access change through a **durable, ordered ingest log**, each entry with a sequence number. - Make every operation **idempotent** and keyed by chunk ID, so applying an entry twice leaves the same state. - Have each copy apply its entries in sequence order, and when it is snapshotted, record the last sequence number it had applied, its **position**. - On restore, pick one target position, then for each copy replay, in order, the log entries that route to it from its own position up to the target. The log must be retained for at least one snapshot interval plus the time to notice a loss and restore, with margin; a gap in the log means a copy can never be brought forward. ## Reconcile before serving Whichever option was used, check before traffic returns: - Compare the set of chunk IDs across all shards with the set in the side store; delete dangling vectors and re-ingest missing ones. - Compare per-document chunk counts with the expected counts recorded at ingest. - Spot-check access lists on a sample of records against the side store. - Run a fixed set of known queries and compare top results with recorded expectations. ## Trade-offs - **Paused cut:** simple and exact, costs an ingestion pause, and needs a coordinator that reaches every node and the side store. - **Positions and replay:** no pause, but it needs an ordered log for every change, idempotent writes and disciplined retention. - **Reconciliation only:** cheaper to set up and catches dangling or missing records, but cannot tell which of two versions of a document is right without a log or the sources. Most teams combine a log-based replay with a reconciliation pass, because the pass also catches bugs in the replay itself.
- The store offers a cluster-wide snapshot call. Is the problem solved?Only if it captures every shard at one logical point, which you must check rather than assume; some implementations run per-shard snapshots in parallel. It also never covers a side store it does not own, such as the text or permission store, so you still need a paused cut or shared log positions across both, plus a reconciliation pass after the restore.
- Why must the ingest log be kept longer than the snapshot interval?Replay starts from each copy's recorded position. If the log has already discarded entries after the oldest copy's position, that gap cannot be replayed and the copies cannot reach one point. Keep the log for at least one snapshot interval plus the time to detect a loss and restore, with a margin.
- Each shard's snapshot is consistent, so the restored cluster is consistent.
- Snapshots taken a few minutes apart are close enough to restore together.
- Vector IDs without matching text are harmless; search just skips them.
- Replaying the ingest log is safe even if writes are not idempotent.
- A cluster-wide snapshot call always covers the separate text store too.