From e06012f5221ac1b79deb3d8d6b034d55b7fed54d Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Sat, 10 Nov 2018 06:55:52 -0800 Subject: [PATCH] Correct lease with check quorum. --- src/raft.rs | 7 ++----- tests/integration_cases/test_raft.rs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/raft.rs b/src/raft.rs index 4457babb1..e2482068e 100644 --- a/src/raft.rs +++ b/src/raft.rs @@ -1427,14 +1427,11 @@ impl Raft { self.bcast_heartbeat_with_ctx(Some(ctx)); } ReadOnlyOption::LeaseBased => { - let mut read_index = INVALID_INDEX; - if self.check_quorum { - read_index = self.raft_log.committed - } + let mut read_index = self.raft_log.committed; if m.get_from() == INVALID_ID || m.get_from() == self.id { // from local member let rs = ReadState { - index: self.raft_log.committed, + index: read_index, request_ctx: m.take_entries()[0].take_data(), }; self.read_states.push(rs); diff --git a/tests/integration_cases/test_raft.rs b/tests/integration_cases/test_raft.rs index cacbeb7be..00246596d 100644 --- a/tests/integration_cases/test_raft.rs +++ b/tests/integration_cases/test_raft.rs @@ -2308,7 +2308,7 @@ fn test_read_only_option_lease_without_check_quorum() { let read_states = &nt.peers[&2].read_states; assert!(!read_states.is_empty()); let rs = &read_states[0]; - assert_eq!(rs.index, INVALID_ID); + assert_eq!(rs.index, 1); let vec_ctx = ctx.as_bytes().to_vec(); assert_eq!(rs.request_ctx, vec_ctx); }