szetszwo commented on code in PR #958:
URL: https://github.com/apache/ratis/pull/958#discussion_r1384392974
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ReadRequests.java:
##########
@@ -92,9 +99,15 @@ Consumer<Long> getAppliedIndexConsumer() {
}
CompletableFuture<Long> waitToAdvance(long readIndex) {
- if (stateMachine.getLastAppliedTermIndex().getIndex() >= readIndex) {
- return CompletableFuture.completedFuture(readIndex);
+ final long lastApplied = stateMachine.getLastAppliedTermIndex().getIndex();
+ if (lastApplied >= readIndex) {
+ return CompletableFuture.completedFuture(lastApplied);
+ }
+ final CompletableFuture<Long> f = readIndexQueue.add(readIndex);
+ final long current = stateMachine.getLastAppliedTermIndex().getIndex();
+ if (current >= lastApplied) {
Review Comment:
This should be `current > lastApplied`; otherwise, the condition is always
true.
The change looks good other than that.
--
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]