File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
server/src/main/java/org/elasticsearch/repositories Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 2929import org .elasticsearch .snapshots .SnapshotInfo ;
3030import org .elasticsearch .snapshots .SnapshotState ;
3131import org .elasticsearch .snapshots .SnapshotsService ;
32+ import org .elasticsearch .threadpool .ThreadPool ;
3233import org .elasticsearch .xcontent .XContentBuilder ;
3334import org .elasticsearch .xcontent .XContentParser ;
3435
@@ -377,6 +378,7 @@ private static boolean isIndexToUpdateAfterRemovingSnapshots(
377378 * @return map of index to index metadata blob id to delete
378379 */
379380 public Map <IndexId , Collection <String >> indexMetaDataToRemoveAfterRemovingSnapshots (Collection <SnapshotId > snapshotIds ) {
381+ assert ThreadPool .assertCurrentThreadPool (ThreadPool .Names .SNAPSHOT );
380382 Iterator <IndexId > indicesForSnapshot = indicesToUpdateAfterRemovingSnapshot (snapshotIds );
381383 final Set <String > allRemainingIdentifiers = indexMetaDataGenerations .lookup .entrySet ()
382384 .stream ()
Original file line number Diff line number Diff line change @@ -1134,14 +1134,20 @@ private void runWithUniqueShardMetadataNaming(ActionListener<RepositoryData> rep
11341134 );
11351135 })
11361136
1137- .<RepositoryData >andThen ((l , newRepositoryData ) -> {
1138- l .onResponse (newRepositoryData );
1139- // Once we have updated the repository, run the unreferenced blobs cleanup in parallel to shard-level snapshot deletion
1140- try (var refs = new RefCountingRunnable (onCompletion )) {
1141- cleanupUnlinkedRootAndIndicesBlobs (newRepositoryData , refs .acquireListener ());
1142- cleanupUnlinkedShardLevelBlobs (refs .acquireListener ());
1137+ .<RepositoryData >andThen (
1138+ // writeIndexGen finishes on master-service thread so must fork here.
1139+ snapshotExecutor ,
1140+ threadPool .getThreadContext (),
1141+ (l , newRepositoryData ) -> {
1142+ l .onResponse (newRepositoryData );
1143+ // Once we have updated the repository, run the unreferenced blobs cleanup in parallel to shard-level snapshot
1144+ // deletion
1145+ try (var refs = new RefCountingRunnable (onCompletion )) {
1146+ cleanupUnlinkedRootAndIndicesBlobs (newRepositoryData , refs .acquireListener ());
1147+ cleanupUnlinkedShardLevelBlobs (refs .acquireListener ());
1148+ }
11431149 }
1144- } )
1150+ )
11451151
11461152 .addListener (repositoryDataUpdateListener );
11471153 }
You can’t perform that action at this time.
0 commit comments