Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spurious Warnings During Snapshot Delete (#75911) #75919

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.carrotsearch.hppc.IntHashSet;
import com.carrotsearch.hppc.IntSet;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
Expand All @@ -33,6 +36,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.CloseableChannel;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
Expand All @@ -59,6 +63,7 @@
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.MockLogAppender;
import org.elasticsearch.test.disruption.BusyMasterServiceDisruption;
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
import org.elasticsearch.test.rest.FakeRestRequest;
Expand Down Expand Up @@ -1305,6 +1310,38 @@ public void testConcurrentSnapshotAndRepoDelete() throws Exception {
}
}

public void testDeleteSnapshotsOfDifferentIndexSets() throws IllegalAccessException {
internalCluster().startMasterOnlyNodes(1);
internalCluster().startDataOnlyNode();
final String repoName = "test-repo";
createRepository(repoName, "fs");

final MockLogAppender mockAppender = new MockLogAppender();
mockAppender.addExpectation(
new MockLogAppender.UnseenEventExpectation("no warnings", BlobStoreRepository.class.getCanonicalName(), Level.WARN, "*")
);
mockAppender.start();
final Logger logger = LogManager.getLogger(BlobStoreRepository.class);
Loggers.addAppender(logger, mockAppender);
try {
final String index1 = "index-1";
final String index2 = "index-2";
createIndexWithContent("index-1");
createIndexWithContent("index-2");
createFullSnapshot(repoName, "full-snapshot");
final String snapshot1 = "index-1-snapshot";
final String snapshot2 = "index-2-snapshot";
createSnapshot(repoName, snapshot1, org.elasticsearch.core.List.of(index1));
createSnapshot(repoName, snapshot2, org.elasticsearch.core.List.of(index2));

clusterAdmin().prepareDeleteSnapshot(repoName, snapshot1, snapshot2).get();
mockAppender.assertAllExpectationsMatched();
} finally {
Loggers.removeAppender(logger, mockAppender);
mockAppender.stop();
}
}

private long calculateTotalFilesSize(List<Path> files) {
return files.stream().mapToLong(f -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,12 +1004,13 @@ private void writeUpdatedShardMetaDataAndComputeDeletes(
);

for (IndexId indexId : indices) {
final Set<SnapshotId> survivingSnapshots = oldRepositoryData.getSnapshots(indexId)
.stream()
final Set<SnapshotId> snapshotsWithIndex = org.elasticsearch.core.Set.copyOf(oldRepositoryData.getSnapshots(indexId));
final Set<SnapshotId> survivingSnapshots = snapshotsWithIndex.stream()
.filter(id -> snapshotIds.contains(id) == false)
.collect(Collectors.toSet());
final StepListener<Collection<Integer>> shardCountListener = new StepListener<>();
final Collection<String> indexMetaGenerations = snapshotIds.stream()
.filter(snapshotsWithIndex::contains)
.map(id -> oldRepositoryData.indexMetaDataGenerations().indexMetaBlobId(id, indexId))
.collect(Collectors.toSet());
final ActionListener<Integer> allShardCountsListener = new GroupedActionListener<>(
Expand Down