Skip to content

Commit

Permalink
Make unwrapCorrupt Check Suppressed Ex.
Browse files Browse the repository at this point in the history
* As discussed in #24800 we want to check for suppressed corruption
indicating exceptions here as well to more reliably categorize
corruption related exceptions
* Closes #24800, 41201
  • Loading branch information
original-brownbear committed May 8, 2019
1 parent d94b147 commit 094d17e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions server/src/main/java/org/elasticsearch/ExceptionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,17 @@ public static <T extends Throwable> T useOrSuppress(T first, T second) {
}

public static IOException unwrapCorruption(Throwable t) {
return (IOException) unwrap(t, CorruptIndexException.class,
IndexFormatTooOldException.class,
IndexFormatTooNewException.class);
IOException corruptionException =
(IOException) unwrap(t, CorruptIndexException.class, IndexFormatTooOldException.class, IndexFormatTooNewException.class);
if (corruptionException == null && t != null) {
for (Throwable suppressed : t.getSuppressed()) {
corruptionException = unwrapCorruption(suppressed);
if (corruptionException != null) {
return corruptionException;
}
}
}
return corruptionException;
}

public static Throwable unwrap(Throwable t, Class<?>... clazzes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,12 @@ protected void failEngine(IOException cause) {
handler.sendFiles(store, metas.toArray(new StoreFileMetaData[0]), () -> 0);
fail("exception index");
} catch (RuntimeException ex) {
assertNull(ExceptionsHelper.unwrapCorruption(ex));
final IOException unwrappedCorruption = ExceptionsHelper.unwrapCorruption(ex);
if (throwCorruptedIndexException) {
assertNotNull(unwrappedCorruption);
assertEquals(ex.getMessage(), "[File corruption occurred on recovery but checksums are ok]");
} else {
assertNull(unwrappedCorruption);
assertEquals(ex.getMessage(), "boom");
}
} catch (CorruptIndexException ex) {
Expand Down

0 comments on commit 094d17e

Please sign in to comment.