|
|
@@ -1115,7 +1115,18 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|
|
protected void doRun() {
|
|
|
try {
|
|
|
if (alreadyFailed.get() == false) {
|
|
|
- snapshotFile(snapshotFileInfo, indexId, shardId, snapshotId, snapshotStatus, store);
|
|
|
+ if (store.tryIncRef()) {
|
|
|
+ try {
|
|
|
+ snapshotFile(snapshotFileInfo, indexId, shardId, snapshotId, snapshotStatus, store);
|
|
|
+ } finally {
|
|
|
+ store.decRef();
|
|
|
+ }
|
|
|
+ } else if (snapshotStatus.isAborted()) {
|
|
|
+ throw new IndexShardSnapshotFailedException(shardId, "Aborted");
|
|
|
+ } else {
|
|
|
+ assert false : "Store was closed before aborting the snapshot";
|
|
|
+ throw new IllegalStateException("Store is closed already");
|
|
|
+ }
|
|
|
}
|
|
|
filesListener.onResponse(null);
|
|
|
} catch (IOException e) {
|
|
|
@@ -1316,7 +1327,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|
|
IndexShardSnapshotStatus snapshotStatus, Store store) throws IOException {
|
|
|
final BlobContainer shardContainer = shardContainer(indexId, shardId);
|
|
|
final String file = fileInfo.physicalName();
|
|
|
- store.incRef();
|
|
|
try (IndexInput indexInput = store.openVerifyingInput(file, IOContext.READONCE, fileInfo.metadata())) {
|
|
|
for (int i = 0; i < fileInfo.numberOfParts(); i++) {
|
|
|
final long partBytes = fileInfo.partBytes(i);
|
|
|
@@ -1356,8 +1366,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|
|
failStoreIfCorrupted(store, t);
|
|
|
snapshotStatus.addProcessedFile(0);
|
|
|
throw t;
|
|
|
- } finally {
|
|
|
- store.decRef();
|
|
|
}
|
|
|
}
|
|
|
|