[ENGINE] Remove the ability to flush without flushing the translog
This is a leftover from the times where we failed a flush when recoveries are ongoing. This code is really not needed anymore and we can luckily flush the translog all the time as well.
This commit is contained in:
parent
f7696ec149
commit
03e5149994
|
@ -674,15 +674,11 @@ public class InternalEngine extends Engine {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() throws EngineException {
|
public void flush() throws EngineException {
|
||||||
flush(true, false, false);
|
flush(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush(boolean force, boolean waitIfOngoing) throws EngineException {
|
public void flush(boolean force, boolean waitIfOngoing) throws EngineException {
|
||||||
flush(true, force, waitIfOngoing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void flush(boolean commitTranslog, boolean force, boolean waitIfOngoing) throws EngineException {
|
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
/*
|
/*
|
||||||
* Unfortunately the lock order is important here. We have to acquire the readlock first otherwise
|
* Unfortunately the lock order is important here. We have to acquire the readlock first otherwise
|
||||||
|
@ -706,37 +702,21 @@ public class InternalEngine extends Engine {
|
||||||
logger.trace("acquired flush lock immediately");
|
logger.trace("acquired flush lock immediately");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (commitTranslog) {
|
if (flushNeeded || force) {
|
||||||
if (flushNeeded || force) {
|
flushNeeded = false;
|
||||||
flushNeeded = false;
|
final long translogId;
|
||||||
try {
|
|
||||||
translog.prepareCommit();
|
|
||||||
logger.trace("starting commit for flush; commitTranslog=true");
|
|
||||||
commitIndexWriter(indexWriter, translog);
|
|
||||||
logger.trace("finished commit for flush");
|
|
||||||
translog.commit();
|
|
||||||
// we need to refresh in order to clear older version values
|
|
||||||
refresh("version_table_flush");
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new FlushFailedEngineException(shardId, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// note, its ok to just commit without cleaning the translog, its perfectly fine to replay a
|
|
||||||
// translog on an index that was opened on a committed point in time that is "in the future"
|
|
||||||
// of that translog
|
|
||||||
// we allow to *just* commit if there is an ongoing recovery happening...
|
|
||||||
// its ok to use this, only a flush will cause a new translogFileGeneration, and we are locked here from
|
|
||||||
// other flushes use flushLock
|
|
||||||
try {
|
try {
|
||||||
logger.trace("starting commit for flush; commitTranslog=false");
|
translog.prepareCommit();
|
||||||
|
logger.trace("starting commit for flush; commitTranslog=true");
|
||||||
commitIndexWriter(indexWriter, translog);
|
commitIndexWriter(indexWriter, translog);
|
||||||
logger.trace("finished commit for flush");
|
logger.trace("finished commit for flush");
|
||||||
|
translog.commit();
|
||||||
|
// we need to refresh in order to clear older version values
|
||||||
|
refresh("version_table_flush");
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new FlushFailedEngineException(shardId, e);
|
throw new FlushFailedEngineException(shardId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* we have to inc-ref the store here since if the engine is closed by a tragic event
|
* we have to inc-ref the store here since if the engine is closed by a tragic event
|
||||||
|
@ -830,7 +810,7 @@ public class InternalEngine extends Engine {
|
||||||
indexWriter.forceMerge(maxNumSegments, true /* blocks and waits for merges*/);
|
indexWriter.forceMerge(maxNumSegments, true /* blocks and waits for merges*/);
|
||||||
}
|
}
|
||||||
if (flush) {
|
if (flush) {
|
||||||
flush(true, true, true);
|
flush(true, true);
|
||||||
}
|
}
|
||||||
if (upgrade) {
|
if (upgrade) {
|
||||||
logger.info("finished segment upgrade");
|
logger.info("finished segment upgrade");
|
||||||
|
@ -857,7 +837,7 @@ public class InternalEngine extends Engine {
|
||||||
// the to a write lock when we fail the engine in this operation
|
// the to a write lock when we fail the engine in this operation
|
||||||
if (flushFirst) {
|
if (flushFirst) {
|
||||||
logger.trace("start flush for snapshot");
|
logger.trace("start flush for snapshot");
|
||||||
flush(false, false, true);
|
flush(false, true);
|
||||||
logger.trace("finish flush for snapshot");
|
logger.trace("finish flush for snapshot");
|
||||||
}
|
}
|
||||||
try (ReleasableLock lock = readLock.acquire()) {
|
try (ReleasableLock lock = readLock.acquire()) {
|
||||||
|
|
Loading…
Reference in New Issue