Die with dignity on the Lucene layer#21721
Merged
jasontedor merged 3 commits intoelastic:masterfrom Nov 22, 2016
Merged
Conversation
Contributor
|
I tried to write a test for this here: diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
index 19b50c3..af3a8b3 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
@@ -26,6 +26,8 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.filter.RegexFilter;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Field;
@@ -227,10 +229,13 @@ public class InternalEngineTests extends ESTestCase {
engine.config().setEnableGcDeletes(false);
}
}
-
public EngineConfig copy(EngineConfig config, EngineConfig.OpenMode openMode) {
+ return copy(config, openMode, config.getAnalyzer());
+ }
+
+ public EngineConfig copy(EngineConfig config, EngineConfig.OpenMode openMode, Analyzer analyzer) {
return new EngineConfig(openMode, config.getShardId(), config.getThreadPool(), config.getIndexSettings(), config.getWarmer(),
- config.getStore(), config.getDeletionPolicy(), config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
+ config.getStore(), config.getDeletionPolicy(), config.getMergePolicy(), analyzer, config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getTranslogRecoveryPerformer(), config.getQueryCache(),
config.getQueryCachingPolicy(), config.getTranslogConfig(), config.getFlushMergesAfter(), config.getRefreshListeners(),
config.getMaxUnsafeAutoIdTimestamp());
@@ -2849,4 +2854,33 @@ public class InternalEngineTests extends ESTestCase {
assertTrue(internalEngine.failedEngine.get() instanceof MockDirectoryWrapper.FakeIOException);
}
}
+
+ public void testTragicEventErrorBubblesUp() throws IOException {
+ engine.close();
+ AtomicBoolean failOOM = new AtomicBoolean(true);
+ engine = new InternalEngine(copy(engine.config(), EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, new Analyzer() {
+
+ @Override
+ protected TokenStreamComponents createComponents(String fieldName) {
+ return new TokenStreamComponents(new Tokenizer() {
+ @Override
+ public boolean incrementToken() throws IOException {
+ if (failOOM.get()) {
+ throw new OutOfMemoryError("boom");
+ } else {
+ throw new AssertionError("should not get to this point");
+ }
+ }
+ });
+ }
+ }));
+ Document document = testDocument();
+ document.add(new TextField("value", "test", Field.Store.YES));
+ ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, document, B_1, null);
+ Engine.Index first = new Engine.Index(newUid("1"), doc);
+ expectThrows(OutOfMemoryError.class, () -> engine.index(first));
+ failOOM.set(false);
+ expectThrows(OutOfMemoryError.class, () -> engine.index(first));
+ assertNull(engine.failedEngine.get()); // this is null here since we don't try to fail the engine if tragic even is an error.. should we?
+ }
}feel free to use it |
s1monw
reviewed
Nov 21, 2016
Contributor
There was a problem hiding this comment.
should we still try to fail the engine here?
Member
Author
There was a problem hiding this comment.
I don't think so, the node is going to tear itself down anyway.
Contributor
There was a problem hiding this comment.
I'd feel better if we do since if there is a bug catching that error somehow we didn't fail the shard?
Contributor
There was a problem hiding this comment.
oh I see that means we gotta pass Throwable to failEngine hmm not sure here... ok I guess I am ok with not failing
96c4116 to
b07878f
Compare
Member
Author
Contributor
|
LGTM |
When a fatal error tragically closes an index writer, such an error never makes its way to the uncaught exception handler. This prevents the node from being torn down if an out of memory error or other fatal error is thrown in the Lucene layer. This commit ensures that such events bubble their way up to the uncaught exception handler.
This commit adds a unit test that when an index writer is closed tragically, if it is due to a fatal error then that error bubbles up.
b07878f to
309d97a
Compare
This commit removes an extra space in InternalEngineTests#testTragicEventErrorBubblesUp.
jasontedor
added a commit
that referenced
this pull request
Nov 22, 2016
When a fatal error tragically closes an index writer, such an error never makes its way to the uncaught exception handler. This prevents the node from being torn down if an out of memory error or other fatal error is thrown in the Lucene layer. This commit ensures that such events bubble their way up to the uncaught exception handler. Relates #21721
jasontedor
added a commit
that referenced
this pull request
Nov 22, 2016
When a fatal error tragically closes an index writer, such an error never makes its way to the uncaught exception handler. This prevents the node from being torn down if an out of memory error or other fatal error is thrown in the Lucene layer. This commit ensures that such events bubble their way up to the uncaught exception handler. Relates #21721
Member
Author
|
Thanks for all your help on this one @s1monw. ❤️ |
Contributor
|
YW @jasontedor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a fatal error tragically closes an index writer, such an error
never makes its way to the uncaught exception handler. This prevents the
node from being torn down if an out of memory error or other fatal error
is thrown in the Lucene layer. This commit ensures that such events
bubble their way up to the uncaught exception handler.
Relates #19272