Skip to content

Commit 9640726

Browse files
Fix Background Merge Breaking Snapshot Restore Test (#63579) (#64129)
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 bd07e44 commit 9640726

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;
@@ -565,11 +564,8 @@ public void testRestoreIndexWithMissingShards() throws Exception {
565564

566565
public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
567566
logger.info("--> start 2 nodes");
568-
Settings nodeSettings = Settings.builder()
569-
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
570-
.build();
571567

572-
internalCluster().startNodes(2, nodeSettings);
568+
internalCluster().startNodes(2);
573569
cluster().wipeIndices("_all");
574570

575571
createRepository("test-repo", "fs");
@@ -581,6 +577,10 @@ public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
581577

582578
indexRandomDocs("test-idx", 100);
583579

580+
logger.info("--> force merging down to a single segment to get a deterministic set of files");
581+
assertEquals(client().admin().indices().prepareForceMerge("test-idx").setMaxNumSegments(1).setFlush(true).get().getFailedShards(),
582+
0);
583+
584584
createSnapshot("test-repo", "test-snap-1", Collections.singletonList("test-idx"));
585585

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

0 commit comments

Comments
 (0)