RATIS-2102. AsyncApi#send() is not handling retry and reply correctly for replication levels higher than MAJORITY #1104
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?
Background: RATIS-1994 adds a feature allowing
AsyncApi#send()
to return only when a specified replication level is reached. This was done by addingwaitForReplication()
in RaftServer.However, two bugs are found with RATIS-1994 when the (write) replication level is set to higher than
MAJORITY
(the default):When the request is retried (e.g. when timed out), the future retrieved from cache is not correctly waited on with
waitForReplication()
again. This causes divergence in the desired behavior depending on if the request is retried or not. This is fixed by invoking waitForReplication() inwriteAsync()
rather thanappendTransaction()
.waitForReplication()
's watch request reply was incorrectly ignored, this is fixed by combining the reply from write and watch together usingcombineReplies()
.Thanks @szetszwo for the help during debugging and making the patch.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2102
How was this patch tested?
testWriteAsyncCustomReplicationLevel
.