From 7d1eb6e900e34a1a0567d3722edc3c7b855a697d Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 18 May 2015 16:47:24 +0200 Subject: [PATCH] [ENGINE] Close Translog if initial commit fails --- .../org/elasticsearch/index/engine/InternalEngine.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; }