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
This commit is contained in:
Armin Braun 2020-10-26 09:34:43 +01:00 committed by GitHub
parent bd07e44c9a
commit 96407268a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -43,7 +43,6 @@ import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.CheckedFunction;
import org.elasticsearch.common.ParseField;
@ -565,11 +564,8 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
logger.info("--> start 2 nodes");
Settings nodeSettings = Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
.build();
internalCluster().startNodes(2, nodeSettings);
internalCluster().startNodes(2);
cluster().wipeIndices("_all");
createRepository("test-repo", "fs");
@ -581,6 +577,10 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
indexRandomDocs("test-idx", 100);
logger.info("--> force merging down to a single segment to get a deterministic set of files");
assertEquals(client().admin().indices().prepareForceMerge("test-idx").setMaxNumSegments(1).setFlush(true).get().getFailedShards(),
0);
createSnapshot("test-repo", "test-snap-1", Collections.singletonList("test-idx"));
logger.info("--> close the index");