-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: feature flag "single-term-leader": standard raft mode
With this feature on: only one leader can be elected in each term, but reduce LogId size from `LogId:{term, node_id, index}` to `LogId{term, index}`. Add `CommittedLeaderId` as the leader-id type used in `LogId`: The leader-id used in `LogId` can be different(smaller) from leader-id used in `Vote`, depending on `LeaderId` definition. `CommittedLeaderId` is the smallest data that can identify a leader after the leadership is granted by a quorum(committed). Change: Vote stores a LeaderId in it. ```rust // Before pub struct Vote<NID> { pub term: u64, pub node_id: NID, pub committed: bool, } // After pub struct Vote<NID> { #[cfg_attr(feature = "serde", serde(flatten))] pub leader_id: LeaderId<NID>, pub committed: bool, } ``` Upgrade tip: If you manually serialize `Vote`, i.e. without using `serde`, the serialization part should be rewritten. Otherwise, nothing needs to be done. - Fix: #660
- Loading branch information
1 parent
24c212a
commit 4a85ee9
Showing
75 changed files
with
1,195 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Feature flags | ||
|
||
By default openraft enables no features. | ||
|
||
- `bt`: attaches backtrace to generated errors. | ||
|
||
- `serde`: derives `serde::Serialize, serde::Deserialize` for type that are used | ||
in storage and network, such as `Vote` or `AppendEntriesRequest`. | ||
|
||
- `single-term-leader`: allows only one leader to be elected in each `term`. | ||
This is the standard raft policy, which increases election confliction rate | ||
but reduce `LogId`(`(term, node_id, index)` to `(term, index)`) size. | ||
Read more about how it is implemented in [`vote`](./vote.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.