spacemonkd opened a new pull request, #1524:
URL: https://github.com/apache/ratis/pull/1524

   ## What changes were proposed in this pull request?
   
   RATIS-2611. Clear pending queue on all install-snapshot replies
   
   When calling the onNext method, in the various result cases 
[here](https://github.com/apache/ratis/blob/f4c3781468e756220836e88d953fd5598177afdf/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java#L676)
 some cases do not call `removePending()`.
   
   NOT_LEADER
   CONF_MISMATCH
   UNRECOGNIZED
   SNAPSHOT_EXPIRED
   these cases do not clear the pending queue and this may possibly fail on the 
Preconditions.assertSame() check.
   
   `pending.poll()` removes the oldest enqueued request index. The handler 
assumes that for each reply we will have one addPending() and then one 
removePending() call in order.
   
   So if we take an example of chunk install with `SNAPSHOT_EXPIRED`
   
   1. Let us assume we send chunk [0,1,2] -> three `addPending()` calls -> 
pending queue [0, 1, 2]
   2. Reply with chunk 0 as success -> one `removePending()` call -> 
pending.poll() returns 0, condition passed
   3. Reply with chunk 1 as SNAPSHOT_EXPIRED -> pending queue still has [1, 2]
   
   This edge case is handled in the PR.
   
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/RATIS-2611
   
   ## How was this patch tested?
   Unit tests


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