Avoid AssertionError when closing engine (#43638)
Lucene throwing an AlreadyClosedException when closing the engine is fine, and should not trigger an AssertionError. Closes #43626
This commit is contained in:
parent
76d0edd1a4
commit
05b945d010
|
@ -1412,7 +1412,7 @@ public class InternalEngine extends Engine {
|
|||
return new DeleteResult(
|
||||
plan.versionOfDeletion, getPrimaryTerm(), delete.seqNo(), plan.currentlyDeleted == false);
|
||||
} catch (Exception ex) {
|
||||
if (indexWriter.getTragicException() == null) {
|
||||
if (ex instanceof AlreadyClosedException == false && indexWriter.getTragicException() == null) {
|
||||
throw new AssertionError("delete operation should never fail at document level", ex);
|
||||
}
|
||||
throw ex;
|
||||
|
@ -1515,7 +1515,7 @@ public class InternalEngine extends Engine {
|
|||
doc.add(softDeletesField);
|
||||
indexWriter.addDocument(doc);
|
||||
} catch (Exception ex) {
|
||||
if (indexWriter.getTragicException() == null) {
|
||||
if (ex instanceof AlreadyClosedException == false && indexWriter.getTragicException() == null) {
|
||||
throw new AssertionError("noop operation should never fail at document level", ex);
|
||||
}
|
||||
throw ex;
|
||||
|
|
|
@ -98,7 +98,6 @@ public class DiskDisruptionIT extends AbstractDisruptionTestCase {
|
|||
* It simulates a full power outage by preventing translog checkpoint files to be written and restart the cluster. This means that
|
||||
* all un-fsynced data will be lost.
|
||||
*/
|
||||
@AwaitsFix( bugUrl = "https://github.com/elastic/elasticsearch/issues/43626")
|
||||
public void testGlobalCheckpointIsSafe() throws Exception {
|
||||
startCluster(rarely() ? 5 : 3);
|
||||
|
||||
|
|
|
@ -5595,6 +5595,37 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
expectThrows(AlreadyClosedException.class, () -> engine.acquireSearcher("test"));
|
||||
}
|
||||
|
||||
public void testNoOpOnClosingEngine() throws Exception {
|
||||
engine.close();
|
||||
Settings settings = Settings.builder()
|
||||
.put(defaultSettings.getSettings())
|
||||
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build();
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(
|
||||
IndexMetaData.builder(defaultSettings.getIndexMetaData()).settings(settings).build());
|
||||
assertTrue(indexSettings.isSoftDeleteEnabled());
|
||||
try (Store store = createStore();
|
||||
InternalEngine engine = createEngine(config(indexSettings, store, createTempDir(), NoMergePolicy.INSTANCE, null))) {
|
||||
engine.close();
|
||||
expectThrows(AlreadyClosedException.class, () -> engine.noOp(
|
||||
new Engine.NoOp(2, primaryTerm.get(), LOCAL_TRANSLOG_RECOVERY, System.nanoTime(), "reason")));
|
||||
}
|
||||
}
|
||||
|
||||
public void testSoftDeleteOnClosingEngine() throws Exception {
|
||||
engine.close();
|
||||
Settings settings = Settings.builder()
|
||||
.put(defaultSettings.getSettings())
|
||||
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build();
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(
|
||||
IndexMetaData.builder(defaultSettings.getIndexMetaData()).settings(settings).build());
|
||||
assertTrue(indexSettings.isSoftDeleteEnabled());
|
||||
try (Store store = createStore();
|
||||
InternalEngine engine = createEngine(config(indexSettings, store, createTempDir(), NoMergePolicy.INSTANCE, null))) {
|
||||
engine.close();
|
||||
expectThrows(AlreadyClosedException.class, () -> engine.delete(replicaDeleteForDoc("test", 42, 7, System.nanoTime())));
|
||||
}
|
||||
}
|
||||
|
||||
public void testTrackMaxSeqNoOfUpdatesOrDeletesOnPrimary() throws Exception {
|
||||
engine.close();
|
||||
Set<String> liveDocIds = new HashSet<>();
|
||||
|
|
Loading…
Reference in New Issue