|
110 | 110 | import java.util.Optional;
|
111 | 111 | import java.util.Set;
|
112 | 112 | import java.util.concurrent.Executor;
|
| 113 | +import java.util.concurrent.atomic.AtomicBoolean; |
113 | 114 | import java.util.stream.Collectors;
|
114 | 115 |
|
115 | 116 | import static org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo.canonicalName;
|
@@ -1065,17 +1066,27 @@ public void snapshotShard(Store store, MapperService mapperService, SnapshotId s
|
1065 | 1066 | final GroupedActionListener<Void> filesListener =
|
1066 | 1067 | new GroupedActionListener<>(allFilesUploadedListener, indexIncrementalFileCount);
|
1067 | 1068 | final Executor executor = threadPool.executor(ThreadPool.Names.SNAPSHOT);
|
| 1069 | + // Flag to signal that the snapshot has been aborted/failed so we can stop any further blob uploads from starting |
| 1070 | + final AtomicBoolean alreadyFailed = new AtomicBoolean(); |
1068 | 1071 | for (BlobStoreIndexShardSnapshot.FileInfo snapshotFileInfo : filesToSnapshot) {
|
1069 | 1072 | executor.execute(new ActionRunnable<Void>(filesListener) {
|
1070 | 1073 | @Override
|
1071 | 1074 | protected void doRun() {
|
1072 | 1075 | try {
|
1073 |
| - snapshotFile(snapshotFileInfo, indexId, shardId, snapshotId, snapshotStatus, store); |
| 1076 | + if (alreadyFailed.get() == false) { |
| 1077 | + snapshotFile(snapshotFileInfo, indexId, shardId, snapshotId, snapshotStatus, store); |
| 1078 | + } |
1074 | 1079 | filesListener.onResponse(null);
|
1075 | 1080 | } catch (IOException e) {
|
1076 | 1081 | throw new IndexShardSnapshotFailedException(shardId, "Failed to perform snapshot (index files)", e);
|
1077 | 1082 | }
|
1078 | 1083 | }
|
| 1084 | + |
| 1085 | + @Override |
| 1086 | + public void onFailure(Exception e) { |
| 1087 | + alreadyFailed.set(true); |
| 1088 | + super.onFailure(e); |
| 1089 | + } |
1079 | 1090 | });
|
1080 | 1091 | }
|
1081 | 1092 | } catch (Exception e) {
|
|
0 commit comments