Fixes snapshot deletion handling on in-progress snapshot failure (#23703)

This commit fixes an issue manifested in the
SharedClusterSnapshotRestoreIT#testGetSnapshotsRequest where a delete
request on a snapshot encounters an in-progress snapshot, so it first
tries to abort the snapshot.  During the aborting process, an exception
is thrown which is handled by the snapshot listener's onSnapshotFailure
method.  This method retries the delete snapshot request, only to
encounter that the snapshot is missing, throwing an exception.  It is
possible that the snapshot failure resulted in the snapshot never having
been written to the repository, and hence, there is nothing to delete.
This commit handles the SnapshotMissingException by logging it and
notifying the listener of the missing snapshot.

Closes #23663
This commit is contained in:
Ali Beyad 2017-03-22 21:02:23 -04:00 committed by GitHub
parent a783c6c85c
commit 2df39689fc
1 changed files with 17 additions and 4 deletions

View File

@ -1150,11 +1150,24 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
@Override
public void onSnapshotFailure(Snapshot failedSnapshot, Exception e) {
if (failedSnapshot.equals(snapshot)) {
logger.trace("deleted snapshot failed - deleting files", e);
logger.warn("deleted snapshot failed - deleting files", e);
removeListener(this);
threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() ->
deleteSnapshot(failedSnapshot.getRepository(), failedSnapshot.getSnapshotId().getName(), listener, true)
);
threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() -> {
try {
deleteSnapshot(failedSnapshot.getRepository(),
failedSnapshot.getSnapshotId().getName(),
listener,
true);
} catch (SnapshotMissingException smex) {
logger.info((Supplier<?>) () -> new ParameterizedMessage(
"Tried deleting in-progress snapshot [{}], but it " +
"could not be found after failing to abort.",
smex.getSnapshotName()), e);
listener.onFailure(new SnapshotException(snapshot,
"Tried deleting in-progress snapshot [{}], but it " +
"could not be found after failing to abort.", smex));
}
});
}
}
});