Skip to content

Commit c897140

Browse files
authored
Add cause to assert_no_failure when replay translog (elastic#39333)
We tripped this assertion three times for the last two weeks. However, it only says "this IndexWriter is closed" without the actual cause. ``` [2019-02-14T11:46:31,144][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] fatal error in thread [elasticsearch[node-1][generic][T#2]], exiting java.lang.AssertionError: unexpected failure while replicating translog entry: org.apache.lucene.store.AlreadyClosedException: this IndexWriter is closed ``` This change replaces an assert with an AssertionError so that we will have the actual cause in the next build failures. Relates elastic#38898
1 parent 094309e commit c897140

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.lucene.index.CorruptIndexException;
2424
import org.apache.lucene.index.IndexFormatTooNewException;
2525
import org.apache.lucene.index.IndexFormatTooOldException;
26+
import org.elasticsearch.Assertions;
2627
import org.elasticsearch.ElasticsearchException;
2728
import org.elasticsearch.ExceptionsHelper;
2829
import org.elasticsearch.Version;
@@ -360,8 +361,12 @@ public void indexTranslogOperations(
360361
if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
361362
throw new MapperException("mapping updates are not allowed [" + operation + "]");
362363
}
363-
assert result.getFailure() == null : "unexpected failure while replicating translog entry: " + result.getFailure();
364-
ExceptionsHelper.reThrowIfNotNull(result.getFailure());
364+
if (result.getFailure() != null) {
365+
if (Assertions.ENABLED) {
366+
throw new AssertionError("unexpected failure while replicating translog entry", result.getFailure());
367+
}
368+
ExceptionsHelper.reThrowIfNotNull(result.getFailure());
369+
}
365370
}
366371
// update stats only after all operations completed (to ensure that mapping updates don't mess with stats)
367372
translog.incrementRecoveredOperations(operations.size());

0 commit comments

Comments
 (0)