Repository navigation
RATIS-2399. Avoid locks for commitIndex and snapshotIndex in RaftLogBase - #1612
Merged
Merged
Conversation
szetszwo
reviewed
Oct 3, 2026
szetszwo
reviewed
Nov 13, 2026
Signed-off-by: Elia Renzoni <elia.renzoni03@gmail.com>
Elia-Renzoni
force-pushed
the
refactor/avoid-single-lock
branch
from
November 17, 2026 12:41
55057ec to
8a0adba
Compare
Contributor
Author
|
Thanks for the review. I’ve addressed the suggested changes, and everything seems to work. |
szetszwo
reviewed
Nov 17, 2026
szetszwo
left a comment
Contributor
There was a problem hiding this comment.
@Elia-Renzoni , thanks for the update! The change looks good.
See the minor comments below from Claude:
- Order in updateSnapshotIndex: update commitIndex before snapshotIndex. Without the lock, a reader can briefly see snapshotIndex > commitIndex with the current order. Updating commit first keeps commit >= snapshot true for every reader.
- Dead code: tryWriteLock(TimeDuration) (RaftLogBase.java:362) has no callers now. Remove it, or keep it if external subclasses might use it. It's public, but it isn't declared in the RaftLog interface.
- Trace log text changes from "updateIncreasingly" to "updateToMax old=.., new=.., updated? true". That's fine, but the "updated? " part is redundant because the message only prints when updated is true (RaftLogIndex.java:79). This is optional cleanup in ratis-server-api.
Signed-off-by: Elia Renzoni <elia.renzoni03@gmail.com>
Contributor
Author
I've addressed the suggested cleanups here: 5aac204 |
szetszwo
approved these changes
Nov 18, 2026
szetszwo
left a comment
Contributor
There was a problem hiding this comment.
+1 the change looks good.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Avoid using write locks for both commitIndex and snapshotIndex
What is the link to the Apache JIRA
Jira Issue link:
https://issues.apache.org/jira/browse/RATIS-2399?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
How was this patch tested?
This patch was tested via unit test