issue 4109: Fix Flaky-test: HandleFailuresTest.testHandleFailureBookieNotInWriteSet #4110
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.
Descriptions of the changes in this PR:
Master Issue: #4109
Motivation
Fix Flaky-test: HandleFailuresTest.testHandleFailureBookieNotInWriteSet
When we call
b1Delay.completeExceptionally(new BKException.BKWriteException())
at line480(code1), thepreWriteHook
will complete with exception and then do some actions in the choosen thread(code2), e.g., put the failure bookie todelayedWriteFailedBookies
(code3). So thedelayedWriteFailedBookies
update is async.However,
lh.appendAsync("entry2".getBytes()))
(Line483 in Code4) is invoked in main thread. So whenappendAsync
execute, thedelayedWriteFailedBookies
could be not updated yet, andchangeInProgress.complete(null)
(code5) will never be invoked.We can reproduce this flasy-test if we put
Thread.sleep(5000)
just before line289 at code6.code1:
bookkeeper/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/HandleFailuresTest.java
Line 480 in 907c273
code2:
bookkeeper/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/MockBookieClient.java
Lines 179 to 186 in 907c273
code3:
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
Lines 1848 to 1852 in 907c273
code4:
bookkeeper/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/HandleFailuresTest.java
Lines 480 to 483 in 907c273
code5:
bookkeeper/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/HandleFailuresTest.java
Lines 469 to 472 in 907c273
code6:
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java
Lines 282 to 290 in 907c273
Changes
(Describe: what changes you have made)