Browse Source

Revert #122047 (#122227) (#122320)

(cherry picked from commit 3ec1d12c99b690d129f919764fb4babafae4049d)
Mikhail Berezovskiy 8 months ago
parent
commit
0992956d45

+ 0 - 5
docs/changelog/122047.yaml

@@ -1,5 +0,0 @@
-pr: 122047
-summary: Fork post-snapshot-delete cleanup off master thread
-area: Snapshot/Restore
-type: bug
-issues: []

+ 0 - 6
server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java

@@ -508,12 +508,6 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
             .orElseThrow()
             .queue();
 
-        // There is one task in the queue for computing and forking the cleanup work.
-        assertThat(queueLength.getAsInt(), equalTo(1));
-
-        safeAwait(barrier); // unblock the barrier thread and let it process the queue
-        safeAwait(barrier); // wait for the queue to be processed
-
         // There are indexCount (=3*snapshotPoolSize) index-deletion tasks, plus one for cleaning up the root metadata. However, the
         // throttled runner only enqueues one task per SNAPSHOT thread to start with, and then the eager runner adds another one. This shows
         // we are not spamming the threadpool with all the tasks at once, which means that other snapshot activities can run alongside this

+ 0 - 2
server/src/main/java/org/elasticsearch/repositories/RepositoryData.java

@@ -29,7 +29,6 @@ import org.elasticsearch.snapshots.SnapshotId;
 import org.elasticsearch.snapshots.SnapshotInfo;
 import org.elasticsearch.snapshots.SnapshotState;
 import org.elasticsearch.snapshots.SnapshotsService;
-import org.elasticsearch.threadpool.ThreadPool;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentParser;
 
@@ -378,7 +377,6 @@ public final class RepositoryData {
      * @return map of index to index metadata blob id to delete
      */
     public Map<IndexId, Collection<String>> indexMetaDataToRemoveAfterRemovingSnapshots(Collection<SnapshotId> snapshotIds) {
-        assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SNAPSHOT);
         Iterator<IndexId> indicesForSnapshot = indicesToUpdateAfterRemovingSnapshot(snapshotIds);
         final Set<String> allRemainingIdentifiers = indexMetaDataGenerations.lookup.entrySet()
             .stream()

+ 7 - 13
server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java

@@ -1129,20 +1129,14 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
                     );
                 })
 
-                .<RepositoryData>andThen(
-                    // writeIndexGen finishes on master-service thread so must fork here.
-                    snapshotExecutor,
-                    threadPool.getThreadContext(),
-                    (l, newRepositoryData) -> {
-                        l.onResponse(newRepositoryData);
-                        // Once we have updated the repository, run the unreferenced blobs cleanup in parallel to shard-level snapshot
-                        // deletion
-                        try (var refs = new RefCountingRunnable(onCompletion)) {
-                            cleanupUnlinkedRootAndIndicesBlobs(newRepositoryData, refs.acquireListener());
-                            cleanupUnlinkedShardLevelBlobs(refs.acquireListener());
-                        }
+                .<RepositoryData>andThen((l, newRepositoryData) -> {
+                    l.onResponse(newRepositoryData);
+                    // Once we have updated the repository, run the unreferenced blobs cleanup in parallel to shard-level snapshot deletion
+                    try (var refs = new RefCountingRunnable(onCompletion)) {
+                        cleanupUnlinkedRootAndIndicesBlobs(newRepositoryData, refs.acquireListener());
+                        cleanupUnlinkedShardLevelBlobs(refs.acquireListener());
                     }
-                )
+                })
 
                 .addListener(repositoryDataUpdateListener);
         }