ivandika3 commented on PR #1700:
URL: https://github.com/apache/ratis/pull/1700#issuecomment-7001952095

   Thanks @szetszwo for the review. 
   
   > (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.
   
   Yes, currently it has no observed possible deadlock. I was trying a 
different ways like introducing lock to `FollowerInfoImpl`, but this means that 
lock ordering need to be preserved and things like `computeNextindex` that can 
take any arbitrary function can introduce deadlock.
   
   > 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: ...
   
   The proposed `setNextIndex` replacement is not equivalent. We use the CAS 
retry as a way to get the latest matchIndex to recompute the 
getNextIndexForInconsistency. If we simply use `setNextIndex`, we only 
calculate the matchIndex once and it can be updated by a newer value instead.
   
   > 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.
   
   Good catch, removed the subsequent `setSnapshotIndex`.
   
   > 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.
   
   Let's address it in the new follow-up task, raised RATIS-2824.
   
   > increaseNextIndex now has one caller: LogAppenderDefault.java:210. That's 
fine because that appender is synchronous.
   
   Yes, correct.
   
   
   


-- 
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]

Reply via email to