szetszwo commented on PR #1700:
URL: https://github.com/apache/ratis/pull/1700#issuecomment-6987120635
@ivandika3 , the change looks good.
Just some minor comments from Claude:
> ... might risk issues like deadlock. ...
- (Claude) I checked the new write locks in the snapshot paths for deadlock:
none of them run inside another lock, and the read lock in hasAllResponse is
released before installSnapshot takes the write lock.
Suggestions
1. computeNextIndex(ignored -> getNextIndexForInconsistency(...))
(GrpcLogAppender.java:642) behaves like setNextIndex, but the lambda ignores
its input, which hides that. There is also a small side effect:
- RaftLogIndex.updateUnconditionally runs the function twice: once inside
getAndUpdate (which can retry) and once more to build the log message.
- The function reads matchIndex, which the SUCCESS path can change at any
time, so the logged new value can differ from what was stored.
- setNextIndex(getNextIndexForInconsistency(requestFirstIndex,
replyNextIndex)) inside the lock would be clearer and does the same thing.
2. updateNextIndexForSnapshot right after setSnapshotIndex is redundant.
setSnapshotIndex already sets nextIndex = idx+1, so the extra call usually does
nothing except add an INFO log line. It was redundant before this change too,
so it's fine to drop or keep.
3. Older issue, not introduced here: FollowerInfoImpl.setSnapshotIndex
overwrites matchIndex and nextIndex unconditionally. The SUCCESS path doesn't
take the lock, so wrapping the call in the lock doesn't stop a concurrent
reply's progress from being overwritten with a lower value. The effect is
conservative (it only re-sends entries), and your new comment ("Successful
append replies may advance the indexes independently") already acknowledges it.
It could be a follow-up.
4. increaseNextIndex now has one caller: LogAppenderDefault.java:210. That's
fine because that appender is synchronous.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]