From 62feea087b432dc2b5c31007c6c0210cb93144c4 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Wed, 6 Sep 2023 09:23:56 +0530 Subject: [PATCH] Fix SharedClusterSnapshotRestoreIT and RestoreSnapshotIT Signed-off-by: Sachin Kale --- .../org/opensearch/index/engine/NRTReplicationEngine.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java b/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java index 3cc9ec8e16493..42f99da341d0f 100644 --- a/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java @@ -24,6 +24,7 @@ import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.index.translog.Translog; +import org.opensearch.index.translog.TranslogCorruptedException; import org.opensearch.index.translog.TranslogDeletionPolicy; import org.opensearch.index.translog.TranslogException; import org.opensearch.index.translog.TranslogManager; @@ -127,8 +128,9 @@ public void onAfterTranslogSync() { engineConfig.getPrimaryModeSupplier() ); this.translogManager = translogManagerRef; - } catch (IOException e) { - IOUtils.closeWhileHandlingException(store::decRef, readerManager, translogManagerRef); + } catch (IOException | TranslogCorruptedException e) { + store.decRef(); + IOUtils.closeWhileHandlingException(readerManager, translogManagerRef); throw new EngineCreationFailureException(shardId, "failed to create engine", e); } }