Skip to content

Commit 40945ae

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 a8b21f2 commit 40945ae

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
@@ -384,7 +384,7 @@ private static final void failIfCorrupted(Directory directory, ShardId shardId)
384384
}
385385

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

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

0 commit comments

Comments
 (0)