[ENGINE] sync translog before closing engine

If the translog is buffered we must make sure everything is synced to disk
before we rollback the writer otherwise we open a window for potential dataloss due
to stupid errors preventing the translog from being closed.
This commit is contained in:
Simon Willnauer 2015-04-08 11:47:09 +02:00
parent 6df978e76e
commit f687377e2f
1 changed files with 5 additions and 0 deletions

View File

@ -902,6 +902,11 @@ public class InternalEngine extends Engine {
if (isClosed.compareAndSet(false, true)) {
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself";
try {
try {
translog.sync();
} catch (IOException ex) {
logger.warn("failed to sync translog");
}
this.versionMap.clear();
logger.trace("close searcherManager");
try {