Skip to content

Commit a2d8d7f

Browse files
committed
[CORE] Don't handle FNF exceptions when reading snapshot
We used to handle FNF exceptions in the store when reading a snapshot. For instance if we can't open a segments file for a given commit point we just return an empty metadata object and tracelog the even. This can cause shards to be false marked as corrupted if a shard is forcefully removed while a recovery started at the same time. We should in general bubble up these exceptions and let the caller decided how to handle the IOExceptions.
1 parent abfaada commit a2d8d7f

File tree

1 file changed

+2
-9
lines changed
  • src/main/java/org/elasticsearch/index/store

1 file changed

+2
-9
lines changed

src/main/java/org/elasticsearch/index/store/Store.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private static final void failIfCorrupted(Directory directory, ShardId shardId)
381381
}
382382

383383
/**
384-
* This exists so {@link BloomFilteringPostingsFormat} can load its boolean setting; can we find a more straightforward way?
384+
* This exists so {@link org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat} can load its boolean setting; can we find a more straightforward way?
385385
*/
386386
public class StoreDirectory extends FilterDirectory {
387387

@@ -468,14 +468,7 @@ ImmutableMap<String, StoreFileMetaData> buildMetadata(IndexCommit commit, Direct
468468
ImmutableMap.Builder<String, StoreFileMetaData> builder = ImmutableMap.builder();
469469
Map<String, String> checksumMap = readLegacyChecksums(directory);
470470
try {
471-
final SegmentInfos segmentCommitInfos;
472-
try {
473-
segmentCommitInfos = Store.readSegmentsInfo(commit, directory);
474-
} catch (FileNotFoundException | NoSuchFileException ex) {
475-
// no segments file -- can't read metadata
476-
logger.trace("Can't read segment infos", ex);
477-
return ImmutableMap.of();
478-
}
471+
final SegmentInfos segmentCommitInfos = Store.readSegmentsInfo(commit, directory);
479472
Version maxVersion = Version.LUCENE_3_0; // we don't know which version was used to write so we take the max version.
480473
for (SegmentCommitInfo info : segmentCommitInfos) {
481474
final Version version = info.info.getVersion();

0 commit comments

Comments
 (0)