From a0e9951e8a278c20ee9adbaac11e5743eb723671 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 11 Sep 2014 16:01:04 +0200 Subject: [PATCH] [STORE] Turn unexpected exception into CorruptedIndexException Today if we run into exception like NumberFormatException or IAE when we try to open a commit point to retrieve checksums and calculate store metadata we just bubble them up. Yet, those are very likely index corruptions. In such a case we should really mark the shard as corrupted. --- src/main/java/org/elasticsearch/index/store/Store.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/elasticsearch/index/store/Store.java b/src/main/java/org/elasticsearch/index/store/Store.java index 19aec28e05d..271c4c481ab 100644 --- a/src/main/java/org/elasticsearch/index/store/Store.java +++ b/src/main/java/org/elasticsearch/index/store/Store.java @@ -125,7 +125,12 @@ public class Store extends AbstractIndexShardComponent implements CloseableIndex } catch (EOFException eof) { // TODO this should be caught by lucene - EOF is almost certainly an index corruption throw new CorruptIndexException("Read past EOF while reading segment infos", eof); + } catch (IOException exception) { + throw exception; // IOExceptions like too many open files are not necessarily a corruption - just bubble it up + } catch (Exception ex) { + throw new CorruptIndexException("Hit unexpected exception while reading segment infos", ex); } + } final void ensureOpen() { // for testing