diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index e9b7915cf98..732fc98360d 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -545,27 +545,28 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus } private void cleanupAfterError(Exception exception) { - if(snapshotCreated) { - try { - repositoriesService.repository(snapshot.snapshot().getRepository()) - .finalizeSnapshot(snapshot.snapshot().getSnapshotId(), - snapshot.indices(), - snapshot.startTime(), - ExceptionsHelper.detailedMessage(exception), - 0, - Collections.emptyList(), - snapshot.getRepositoryStateId(), - snapshot.includeGlobalState(), - snapshot.userMetadata()); - } catch (Exception inner) { - inner.addSuppressed(exception); - logger.warn(() -> new ParameterizedMessage("[{}] failed to close snapshot in repository", - snapshot.snapshot()), inner); + threadPool.generic().execute(() -> { + if (snapshotCreated) { + try { + repositoriesService.repository(snapshot.snapshot().getRepository()) + .finalizeSnapshot(snapshot.snapshot().getSnapshotId(), + snapshot.indices(), + snapshot.startTime(), + ExceptionsHelper.detailedMessage(exception), + 0, + Collections.emptyList(), + snapshot.getRepositoryStateId(), + snapshot.includeGlobalState(), + snapshot.userMetadata()); + } catch (Exception inner) { + inner.addSuppressed(exception); + logger.warn(() -> new ParameterizedMessage("[{}] failed to close snapshot in repository", + snapshot.snapshot()), inner); + } } - } - userCreateSnapshotListener.onFailure(e); + userCreateSnapshotListener.onFailure(e); + }); } - } private static SnapshotInfo inProgressSnapshot(SnapshotsInProgress.Entry entry) {