Todd Lipcon has submitted this change and it was merged.
Change subject: consensus: properly truncate all state when aborting operations
consensus: properly truncate all state when aborting operations
This fixes a consensus bug which was causing exactly_once_writes-itest
to be slightly flaky. The issue was the following sequence:
- a node A is a follower, and has some operations appended (eg 10.5 through
- a node B is elected for term 11, and sends node 'A' a status-only request
-- node 'A' aborts operations 10.6 and 10.7
-- HOWEVER: it was not explicitly removing these operations from the
LogCache or the Log. Removal was only happening on an actual
- node 'B' loses its leadership before it is able to replicate anything
to a majority
- node 'A' gets elected for term 12
-- it calls Queue::SetLeaderMode()
-- this triggers the first requests to be sent to the peer
-- we hit a race where the first request is being constructed _before_
the leader appends its initial NO_OP to the queue
--- because we never truncated the log cache or queue, we see operations
10.6 and 10.7 in the queue, and send them to a follower
-- we now append the NO_OP 12.6 which replaces the aborted 10.6.
In this case, the peer who received the fauly request from the leader
may end up committing those operations whereas the rest of the nodes
commit operations from term 12.
The fix in this patch is to explicitly truncate the queue and the
LogCache state when we are aborting operations. WIP because it needs a
few more comments.
To test, I looped exactly_once_writes-itest --gtest_filter=\*Churny\*
1000 times before and after.
Without the patch, I got 17 failures, 16 of which were verification
errors that one of the committed op terms did not match.
With the patch, I got 5 failures, all of which were checksum
errors while verifying the logs. Since seeing those failures, I fixed
the verifier to run only after shutting down the cluster.
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <dral...@apache.org>
15 files changed, 351 insertions(+), 22 deletions(-)
David Ribeiro Alves: Looks good to me, approved
Kudu Jenkins: Verified
To view, visit http://gerrit.cloudera.org:8080/4409
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Owner: Todd Lipcon <t...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dral...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <t...@apache.org>