Skip to content

Commit b98d1c6

Browse files
Fix Background Merge Breaking Snapshot Restore Test (#63579) (#64128)
If we run into a background merge between creating the snapshot and closing the index then with compound files we could be in a situation where we get zero file reuse on restore. Force merging before the snapshot gives us a single segment that won't change down the line so the restore always sees file reuse from the close index. Closes #63476
1 parent 7f333ea commit b98d1c6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
4444
import org.elasticsearch.cluster.metadata.Metadata;
4545
import org.elasticsearch.cluster.node.DiscoveryNode;
46-
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
4746
import org.elasticsearch.cluster.service.ClusterService;
4847
import org.elasticsearch.common.CheckedFunction;
4948
import org.elasticsearch.common.ParseField;
@@ -560,11 +559,8 @@ public void testRestoreIndexWithMissingShards() throws Exception {
560559

561560
public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
562561
logger.info("--> start 2 nodes");
563-
Settings nodeSettings = Settings.builder()
564-
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
565-
.build();
566562

567-
internalCluster().startNodes(2, nodeSettings);
563+
internalCluster().startNodes(2);
568564
cluster().wipeIndices("_all");
569565

570566
createRepository("test-repo", "fs");
@@ -576,6 +572,10 @@ public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
576572

577573
indexRandomDocs("test-idx", 100);
578574

575+
logger.info("--> force merging down to a single segment to get a deterministic set of files");
576+
assertEquals(client().admin().indices().prepareForceMerge("test-idx").setMaxNumSegments(1).setFlush(true).get().getFailedShards(),
577+
0);
578+
579579
createSnapshot("test-repo", "test-snap-1", Collections.singletonList("test-idx"));
580580

581581
logger.info("--> close the index");

0 commit comments

Comments
 (0)