Skip to content

Commit

Permalink
chore: correct cluster version in client
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <[email protected]>
  • Loading branch information
iGxnon committed Jan 3, 2024
1 parent 5781400 commit 60f6e57
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions curp/src/client_new/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ async fn test_unary_fetch_clusters_linearizable() {
cluster_version: 1,
},
2 => FetchClusterResponse {
leader_id: None, // imagine this node is a disconnected candidate
term: 23, // with a high term
leader_id: None,
term: 23, // abnormal term
cluster_id: 123,
members: vec![],
cluster_version: 1,
Expand Down
5 changes: 2 additions & 3 deletions curp/src/client_new/unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ impl<C: Command> Unary<C> {
if !Self::check_and_update_leader(&mut state, res.leader_id, res.term) {
return Ok(());
}
if state.cluster_version >= res.cluster_version {
if state.cluster_version == res.cluster_version {
debug!(
"ignore old cluster version({}) from server",
"ignore cluster version({}) from server",
res.cluster_version
);
return Ok(());
Expand Down Expand Up @@ -644,7 +644,6 @@ impl<C: Command> ClientApi for Unary<C> {
}
};
// Ignore the response of a node that doesn't know who the leader is.
// some disconnected candidates may continue to increase term, disrupting the process below.
if inner.leader_id.is_some() {
#[allow(clippy::integer_arithmetic)]
match max_term.cmp(&inner.term) {
Expand Down
2 changes: 1 addition & 1 deletion xlineapi/proto

0 comments on commit 60f6e57

Please sign in to comment.