Consistency level ALL/QUORUM succeeds with replicas down: level computed over reachable replicas since v1.31, searches never enforce it
Summary
Two problems make consistency level ALL (and QUORUM) succeed while replicas are down. The docs say an ALL read or write fails when any replica does not respond.
- Regression since v1.31.0: writes, deletes and reads by id. The level is computed over the replicas memberlist can still resolve, not over the shard's replica set. Once a down replica has left memberlist, a request at
ALLsucceeds on the remaining replicas.QUORUMbecomes a majority of the remaining replicas: with two of three replicas down, aQUORUMwrite succeeds on one. - Searches have never enforced the level (since v1.19.0). A search at
ALLorQUORUMreturns results when the consistency check fails; the error is only logged. On 1.39.4 it is not even logged, because of (1).
Clients get a success response for a guarantee that was not met. A client that writes at ALL so every replica holds the object gets a 200 while one replica holds nothing.
Measured behavior
3 nodes, multi-tenant collection with replication factor 3, one tenant, objects written while all nodes are up. The StatefulSet is scaled to 2, so one replica is down and has left memberlist. Python client, every request at ConsistencyLevel.ALL unless noted:
| request | 1.26.18 | 1.27.27 | 1.30.23 | 1.31.22 | 1.39.4 |
|---|---|---|---|---|---|
data.insert |
rejected | rejected | rejected | accepted | accepted |
| batch insert | rejected | rejected | rejected | accepted | accepted |
data.exists (REST HEAD) |
rejected | rejected | rejected | accepted | accepted |
data.delete_by_id |
rejected | rejected | rejected | accepted | accepted |
query.fetch_objects / near_vector / fetch_object_by_id (gRPC search) |
accepted | accepted | accepted | accepted | accepted |
data.insert at QUORUM (control) |
accepted | accepted | accepted | accepted | accepted |
"Rejected" is a 500 with cannot achieve consistency level "ALL": cannot reach enough replicas; for a batch, every object fails with that error. On 1.26.18 the searches at ALL log failed to check consistency of search results: pull shard: cannot reach enough replicas and still return results. On 1.39.4 nothing is logged.
On 7 nodes (1.39.4), with two of a tenant's three replicas isolated by iptables: for the ~30 s before memberlist declares them dead, a QUORUM write fails with cannot reach enough replicas: required 2 replicas, got 1. After that, QUORUM and ALL writes both return 200 with one replica alive.
Reproduction
t = collection.with_tenant("T").with_consistency_level(ConsistencyLevel.ALL)
# scale the StatefulSet from 3 to 2 and wait until /v1/nodes lists 2 nodes
t.data.insert({"title": "x"}, vector=[0.1] * 8) # expected: error; 1.31+: stored
t.data.exists(existing_id) # expected: error; 1.31+: True
t.data.delete_by_id(other_id) # expected: error; 1.31+: deleted
t.query.fetch_objects() # expected: error; every version: resultsA pytest reproducer (tests/recovery/python_recovery/replication_test.py::test_consistency_all_rejected_while_a_replica_is_down) is being added to weaviate-e2e-tests: it passes on 1.30.23 and xfails on 1.39.4. It covers (1) only.
Cause
(1), from v1.31.0 (router, #8354):
buildReplicaskeeps only replicas whose hostname resolves.State.NodeHostnamereads the member view, and memberlist'sNotifyLeave, fired for a dead or departed node, removes the node from it.validateReplicaSetConsistencythen computeslevel.ToInt(len(shardReplicas))over that filtered list, soALLcan never exceed the replicas available.- In v1.30,
rState.ConsistencyLevel(usecases/replica/resolver.go) computed the level from all replicas in the sharding state (unresolved ones included) and failed when fewer resolved.
(2), from v1.19.0 (#2781): Index.objectSearch and the vector search path call CheckConsistency after the search and only log its error. The check also covers only the objects the serving replica returned, so it cannot notice objects that replica lacks.
Expected
- Compute the required replica count from the shard's replica set in the sharding state, and fail the request when fewer replicas are reachable, as v1.30 did.
- Return the
CheckConsistencyerror from searches atQUORUM/ALLinstead of logging it, or document that searches do not enforce the consistency level.
Source: weaviate/weaviate