Переглянути джерело

Add cause to assert_no_failure when replay translog (#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 #38898
Nhat Nguyen 6 роки тому
батько
коміт
c897140c06

+ 7 - 2
server/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java

@@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger;
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexFormatTooNewException;
 import org.apache.lucene.index.IndexFormatTooOldException;
+import org.elasticsearch.Assertions;
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.ExceptionsHelper;
 import org.elasticsearch.Version;
@@ -360,8 +361,12 @@ public class RecoveryTarget extends AbstractRefCounted implements RecoveryTarget
                 if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
                     throw new MapperException("mapping updates are not allowed [" + operation + "]");
                 }
-                assert result.getFailure() == null : "unexpected failure while replicating translog entry: " + result.getFailure();
-                ExceptionsHelper.reThrowIfNotNull(result.getFailure());
+                if (result.getFailure() != null) {
+                    if (Assertions.ENABLED) {
+                        throw new AssertionError("unexpected failure while replicating translog entry", result.getFailure());
+                    }
+                    ExceptionsHelper.reThrowIfNotNull(result.getFailure());
+                }
             }
             // update stats only after all operations completed (to ensure that mapping updates don't mess with stats)
             translog.incrementRecoveredOperations(operations.size());