Rethrow original exception when it fails the engine during write operations
This commit is contained in:
parent
947a17ee37
commit
2f883fcb85
|
@ -411,8 +411,7 @@ public class InternalEngine extends Engine {
|
||||||
* Inspects exception thrown when executing index or delete operations
|
* Inspects exception thrown when executing index or delete operations
|
||||||
*
|
*
|
||||||
* @return failure if the failure is a document specific failure (e.g. analysis chain failure)
|
* @return failure if the failure is a document specific failure (e.g. analysis chain failure)
|
||||||
* @throws ElasticsearchException if the failure caused the engine to fail
|
* or throws Exception if the failure caused the engine to fail (e.g. out of disk, lucene tragic event)
|
||||||
* (e.g. out of disk, lucene tragic event)
|
|
||||||
*
|
*
|
||||||
* Note: pkg-private for testing
|
* Note: pkg-private for testing
|
||||||
*/
|
*/
|
||||||
|
@ -435,12 +434,16 @@ public class InternalEngine extends Engine {
|
||||||
if (isDocumentFailure) {
|
if (isDocumentFailure) {
|
||||||
return failure;
|
return failure;
|
||||||
} else {
|
} else {
|
||||||
ElasticsearchException exception = new ElasticsearchException(failure);
|
rethrow(failure);
|
||||||
exception.setShard(shardId);
|
return null;
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
static <T extends Throwable> void rethrow(Throwable t) throws T {
|
||||||
|
throw (T) t;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean canOptimizeAddDocument(Index index) {
|
private boolean canOptimizeAddDocument(Index index) {
|
||||||
if (index.getAutoGeneratedIdTimestamp() != IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP) {
|
if (index.getAutoGeneratedIdTimestamp() != IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP) {
|
||||||
assert index.getAutoGeneratedIdTimestamp() >= 0 : "autoGeneratedIdTimestamp must be positive but was: "
|
assert index.getAutoGeneratedIdTimestamp() >= 0 : "autoGeneratedIdTimestamp must be positive but was: "
|
||||||
|
|
|
@ -2153,9 +2153,8 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
try {
|
try {
|
||||||
engine.checkIfDocumentFailureOrThrow(new Engine.Index(newUid("1"), doc), new CorruptIndexException("simulated environment failure", ""));
|
engine.checkIfDocumentFailureOrThrow(new Engine.Index(newUid("1"), doc), new CorruptIndexException("simulated environment failure", ""));
|
||||||
fail("expected exception to be thrown");
|
fail("expected exception to be thrown");
|
||||||
} catch (ElasticsearchException envirnomentException) {
|
} catch (Exception envirnomentException) {
|
||||||
assertThat(envirnomentException.getShardId(), equalTo(engine.shardId));
|
assertThat(envirnomentException.getMessage(), containsString("simulated environment failure"));
|
||||||
assertThat(envirnomentException.getCause().getMessage(), containsString("simulated environment failure"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue