[ENGINE] Close Translog if initial commit fails

This commit is contained in:
Simon Willnauer 2015-05-18 16:47:24 +02:00
parent a2a41c0115
commit 7d1eb6e900
1 changed files with 9 additions and 1 deletions

View File

@ -194,7 +194,15 @@ public class InternalEngine extends Engine {
final Translog translog = new Translog(translogConfig); final Translog translog = new Translog(translogConfig);
if (generation == null) { if (generation == null) {
logger.debug("no translog ID present in the current generation - creating one"); logger.debug("no translog ID present in the current generation - creating one");
boolean success = false;
try {
commitIndexWriter(writer, translog); commitIndexWriter(writer, translog);
success = true;
} finally {
if (success == false) {
IOUtils.closeWhileHandlingException(translog);
}
}
} }
return translog; return translog;
} }