HDDS-2368. TestOzoneManagerDoubleBufferWithDummyResponse failing intermittently #93
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?
Fix TestOzoneManagerDoubleBufferWithDummyResponse, which (very) intermittently fails at:
Variables are set in one thread (
OzoneManagerDoubleBuffer#daemon
):https://github.com/apache/hadoop-ozone/blob/6a6558025ec35203bfd61839aadf7b2a26520222/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java#L160-L186
and checked in the test thread:
https://github.com/apache/hadoop-ozone/blob/6a6558025ec35203bfd61839aadf7b2a26520222/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBufferWithDummyResponse.java#L110-L117
The test waits for the first variable (
flushedTransactionCount
) to reachbucketCount
. The other variable (totalNumOfFlushedTransactions
) is set later, so the test thread may reach the assertion before the updater thread reachesupdateMetrics
.The proposed fix swaps check of variables in the test: wait for the second variable and let the assertion check the first one. This guarantees that both of them are updated by the time
waitFor
returns.https://issues.apache.org/jira/browse/HDDS-2368
How was this patch tested?
Reproduced the failure by adding some sleep in
OzoneManagerDoubleBuffer#updateMetrics
. Verified the test passes with the fix despite the sleep.