Skip to content

Commit fe1cf86

Browse files
committed
address comment
1 parent 5659eca commit fe1cf86

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,11 +3893,18 @@ private Tuple<BlobStoreIndexShardSnapshots, ShardGeneration> buildBlobStoreIndex
38933893
generation
38943894
);
38953895
} catch (NoSuchFileException noSuchFileException) {
3896-
final long latestGeneration = latestIndexBlobId();
3897-
final RepositoryData currentRepositoryData = getRepositoryData(latestGeneration);
3898-
if (currentRepositoryData.shardGenerations().hasShardGen(new RepositoryShardId(indexId, shardId)) == false) {
3899-
// Master has concurrently mutated the shard generation. This can happen when master fails over
3900-
// which is "expected". We do not need the following workaround in this case.
3896+
// Master may have concurrently mutated the shard generation. This can happen when master fails over
3897+
// which is "expected". We do not need to apply the following workaround for missing file in this case.
3898+
final RepositoryData currentRepositoryData;
3899+
try {
3900+
final long latestGeneration = latestIndexBlobId();
3901+
currentRepositoryData = getRepositoryData(latestGeneration);
3902+
} catch (Exception e) {
3903+
noSuchFileException.addSuppressed(e);
3904+
throw noSuchFileException;
3905+
}
3906+
final ShardGeneration latestShardGen = currentRepositoryData.shardGenerations().getShardGen(indexId, shardId);
3907+
if (latestShardGen == null || latestShardGen.equals(generation) == false) {
39013908
throw noSuchFileException;
39023909
}
39033910

0 commit comments

Comments
 (0)