diff --git a/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index dee7eb2a0a6..dbdb13f03d7 100644 --- a/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -194,7 +194,15 @@ public class InternalEngine extends Engine { final Translog translog = new Translog(translogConfig); if (generation == null) { logger.debug("no translog ID present in the current generation - creating one"); - commitIndexWriter(writer, translog); + boolean success = false; + try { + commitIndexWriter(writer, translog); + success = true; + } finally { + if (success == false) { + IOUtils.closeWhileHandlingException(translog); + } + } } return translog; }