Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Correct lease with check quorum. #141

Merged
merged 6 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,14 +1427,11 @@ impl<T: Storage> Raft<T> {
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);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_cases/test_raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,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);
}
Expand Down