Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: bsearch to find matching log between leader and follower
- Refactor: simplify algo to find matching log between leader and follower. It adopts a binary-search like algo: The leader tracks the max matched log id(`self.matched`) and the least unmatched log id(`self.max_possible_matched_index`). The follower just responds if the `prev_log_id` in AppendEntriesRequest matches the log at `prev_log_id.index` in its store. Remove the case-by-case algo. - Change: RaftStorage adds 2 new API: `try_get_log_entries()`, `first_id_in_log()` and `first_known_log_id()`. These a are not stable, may be removed soon. - Fix: the timeout for `Wait()` should be a total timeout. Otherwise a `Wait()` never quits. - Fix: when send append-entries request, if a log is not found, it should retry loading, but not enter snapshot state. Because a log may be deleted by RaftCore just after Replication read `prev_log_id` from the store. - Refactor: The two replication loop: line-rate loop and snapshot loop should not change the `ReplicationState`, but instead returning an error. Otherwise it has to check the state everywhere. - Refactor: simplify receiving RaftCore messages: split `drain_raft_rx()` into `process_raft_event()` and `try_drain_raft_rx()`. - Feature: a store impl has to add an initial log at index 0 to make the store mathematics complete. - Feature: add `ReplicationError` to describe all errors that is emitted when replicating entries or snapshot.
- Loading branch information