Fix WriteOrdering::Medium and WriteOrdering::Strong semantics (#2053)
`WriteOrdering::Medium` and `WriteOrdering::Strong` were swapped 🤡
This commit is contained in:
parent
e11b519b76
commit
b4e42631b1
@ -1311,8 +1311,8 @@ impl ShardReplicaSet {
|
||||
pub fn leader_peer_for_update(&self, ordering: WriteOrdering) -> Option<PeerId> {
|
||||
match ordering {
|
||||
WriteOrdering::Weak => Some(self.this_peer_id()), // no requirement for consistency
|
||||
WriteOrdering::Medium => self.highest_replica_peer_id(), // consistency with highest replica
|
||||
WriteOrdering::Strong => self.highest_alive_replica_peer_id(), // consistency with highest alive replica
|
||||
WriteOrdering::Medium => self.highest_alive_replica_peer_id(), // consistency with highest alive replica
|
||||
WriteOrdering::Strong => self.highest_replica_peer_id(), // consistency with highest replica
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,15 +60,14 @@ def test_write_ordering(tmp_path: pathlib.Path):
|
||||
"id": 1,
|
||||
"vector": [0.05, 0.61, 0.76, 0.74],
|
||||
"payload": {
|
||||
"city": "Dresden",
|
||||
"city": "Munich",
|
||||
"country": "Germany",
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
# fails as highest peer is dead
|
||||
assert r.status_code == 500
|
||||
# succeeds as Medium selects an Alive peer
|
||||
assert_http_ok(r)
|
||||
|
||||
# write ordering strong
|
||||
r = requests.put(
|
||||
@ -78,14 +77,15 @@ def test_write_ordering(tmp_path: pathlib.Path):
|
||||
"id": 1,
|
||||
"vector": [0.05, 0.61, 0.76, 0.74],
|
||||
"payload": {
|
||||
"city": "Munich",
|
||||
"city": "Dresden",
|
||||
"country": "Germany",
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
# succeeds as Strong selects an Alive peer
|
||||
assert_http_ok(r)
|
||||
|
||||
# fails as highest peer is dead
|
||||
assert r.status_code == 500
|
||||
|
||||
# Restart peer
|
||||
new_url = start_peer(peer_dirs[url_index], f"peer_{url_index}_restarted.log", bootstrap_uri)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user