Closed killme2008 closed 2 weeks ago
The recent refactor in the jraft-core
module includes consolidating BallotBox initialization into a dedicated initBallotBox()
method, integrating it into the node start-up sequence. Additionally, several changes were made across the core, option, and storage classes to improve logging, testing, and error handling mechanisms, particularly addressing consistency issues on node restarts.
File Path | Change Summary |
---|---|
jraft-core/src/main/java/com/.../NodeImpl.java |
Refactor BallotBox initialization logic; added new methods for testing and adjusted timeout handling. |
jraft-core/src/main/java/com/.../BallotBoxOptions.java |
Added lastCommittedIndex field with getter and setter methods. |
jraft-core/src/main/java/com/.../SnapshotExecutor.java |
Introduced getLastSnapshotIndex() method. |
jraft-core/src/main/java/com/.../SnapshotExecutorImpl.java |
Removed comments and annotations from getLastSnapshotIndex() . |
jraft-core/src/test/java/com/.../BallotBoxTest.java |
Added tests for lastCommittedIndex initialization and consistency. |
jraft-extension/java-log-storage-impl/src/main/java/com/.../HybridLogStorage.java |
Added imports and exception handling for directory creation. |
jraft-extension/java-log-storage-impl/src/test/java/com/.../NodeTest.java |
Added assertions and synchronization improvements in test methods. |
Suppressed due to the simplicity and varied nature of the changes.
Objective | Addressed | Explanation |
---|---|---|
Initialize lastCommittedIndex to avoid inconsistent readIndex values after a restart (issue #1049) |
✅ | |
Ensure readIndex() returns consistent values post node restart (issue #1049) |
✅ |
The BallotBox has found its place, In logs and snapshots, a stable base. Through refactor's careful hand, Consistency now rules the land. A node restart, no fear to face, For
lastCommittedIndex
holds the grace.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@fengjiachun Please take a look at some fixes around lastCommittedIndex
in BallotBox
.
Motivation & Modification:
Main changes:
lastCommittedIndex
inBallotBox
to a proper value when restart #1092Result:
1049 , #1092 , #1105
Summary by CodeRabbit
Refactor
BallotBox
to enhance reliability.NodeImpl
to handle log manager capacity before task execution.New Features
getLastSnapshotIndex()
method toSnapshotExecutor
.Tests
BallotBox
andNode
functionalities.NodeTest
.Bug Fixes
IOException
during directory creation inHybridLogStorage
constructor.