amaliujia commented on code in PR #10451:
URL: https://github.com/apache/ozone/pull/10451#discussion_r3370679204
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java:
##########
@@ -805,6 +804,24 @@ public void testInstallSnapshotWithClientWrite() throws
Exception {
assertLogCapture(logCapture, msg);
assertLogCapture(logCapture, "Install Checkpoint is finished");
+ // All newKeys writes have completed (writeFuture.get() above), so the
+ // leader must already contain them.
+ OMMetadataManager leaderOmMetaMgr = leaderOM.getMetadataManager();
+ for (String key : newKeys) {
+ assertNotNull(leaderOmMetaMgr.getKeyTable(
+ TEST_BUCKET_LAYOUT)
+ .get(leaderOmMetaMgr.getOzoneKey(volumeName, bucketName, key)));
+ }
+
+ // Wait for the follower to apply everything the leader has applied; all
+ // writes have completed on the leader, so after this no further snapshot
+ // install (and DB reload) can occur and the follower DB reads below are
+ // safe from "Rocks Database is closed" races.
+ long leaderApplied = leaderOM.getOmRatisServer()
+ .getLastAppliedTermIndex().getIndex();
+ GenericTestUtils.waitFor(() -> followerOM.getOmRatisServer()
+ .getLastAppliedTermIndex().getIndex() >= leaderApplied, 100, 30_000);
+
Review Comment:
I am thinking the logic is more clear and close back to the original test if
we
1. for the first `Thread.sleep(5000);`, we do:
```
GenericTestUtils.waitFor(() -> {
return
followerOM.getOmRatisServer().getLastAppliedTermIndex().getIndex()
>= leaderOMSnapshotIndex - 1;
}, 100, 50_000);
```
2. then for the second `Thread.sleep(5000);`, we do
```
long leaderApplied = leaderOM.getOmRatisServer()
.getLastAppliedTermIndex().getIndex();
GenericTestUtils.waitFor(() -> followerOM.getOmRatisServer()
.getLastAppliedTermIndex().getIndex() >= leaderApplied, 100, 50_000);
```
The core idea for the speedup is not to sleep the fixed 50 seconds but wait
for up to 50 seconds and hopefully the operation finishes earlier.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]