Skip to content

Commit 38277fd

Browse files
authored
Force flush in FullClusterRestartIT#testRecovery (#46956)
If peer recovery happens after indexing, and indexing flushes some shard at the end, then the explicit flush in the test will be a noop. Then replicas will have some uncommitted translog , which is transferred in peer recovery, although all of these operations are in the commit already. If that replica becomes primary (after we restarted the cluster), it will have translog to replay and the test will fail. Another issue in this test is that synced_flush is not a replication action, then the global checkpoint on replicas might be not up to date. We need to either wait for the global checkpoint to be synced or call a replication action to sync it. Closes #46712
1 parent 84d5533 commit 38277fd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ public void testRecovery() throws Exception {
674674
ensureGreen(index);
675675
// Recovering a synced-flush index from 5.x to 6.x might be subtle as a 5.x index commit does not have all 6.x commit tags.
676676
if (randomBoolean()) {
677+
// needs to call a replication action to sync the global checkpoint from primaries to replication.
678+
assertOK(client().performRequest(new Request("POST", "/" + index + "/_refresh")));
677679
// We have to spin synced-flush requests here because we fire the global checkpoint sync for the last write operation.
678680
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit.
679681
assertBusy(() -> {
@@ -688,7 +690,10 @@ public void testRecovery() throws Exception {
688690
});
689691
} else {
690692
// Explicitly flush so we're sure to have a bunch of documents in the Lucene index
691-
assertOK(client().performRequest(new Request("POST", "/_flush")));
693+
Request flushRequest = new Request("POST", "/" + index + "/_flush");
694+
flushRequest.addParameter("force", "true");
695+
flushRequest.addParameter("wait_if_ongoing", "true");
696+
assertOK(client().performRequest(flushRequest));
692697
}
693698
if (shouldHaveTranslog) {
694699
// Update a few documents so we are sure to have a translog

0 commit comments

Comments
 (0)