Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IndexWriter.hasPendingChanges() to detect if a flush is needed. #12146

Merged
merged 1 commit into from Jul 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -90,9 +90,6 @@ public class InternalEngine extends Engine {
private final SearcherFactory searcherFactory;
private final SearcherManager searcherManager;

// we use flushNeeded here, since if there are no changes, then the commit won't write
// will not really happen, and then the commitUserData and the new translog will not be reflected
private volatile boolean flushNeeded = false;
private final Lock flushLock = new ReentrantLock();
private final ReentrantLock optimizeLock = new ReentrantLock();

Expand Down Expand Up @@ -262,7 +259,6 @@ public void create(Create create) throws EngineException {
innerCreate(create);
}
}
flushNeeded = true;
} catch (OutOfMemoryError | IllegalStateException | IOException t) {
maybeFailEngine("create", t);
throw new CreateFailedEngineException(shardId, create, t);
Expand Down Expand Up @@ -368,7 +364,6 @@ public void index(Index index) throws EngineException {
innerIndex(index);
}
}
flushNeeded = true;
} catch (OutOfMemoryError | IllegalStateException | IOException t) {
maybeFailEngine("index", t);
throw new IndexFailedEngineException(shardId, index, t);
Expand Down Expand Up @@ -460,7 +455,6 @@ public void delete(Delete delete) throws EngineException {
ensureOpen();
// NOTE: we don't throttle this when merges fall behind because delete-by-id does not create new segments:
innerDelete(delete);
flushNeeded = true;
} catch (OutOfMemoryError | IllegalStateException | IOException t) {
maybeFailEngine("delete", t);
throw new DeleteFailedEngineException(shardId, delete, t);
Expand Down Expand Up @@ -553,7 +547,6 @@ private void innerDelete(DeleteByQuery delete) throws EngineException {

indexWriter.deleteDocuments(query);
translog.add(new Translog.DeleteByQuery(delete));
flushNeeded = true;
} catch (Throwable t) {
maybeFailEngine("delete_by_query", t);
throw new DeleteByQueryFailedEngineException(shardId, delete, t);
Expand Down Expand Up @@ -668,8 +661,7 @@ private CommitId flush(boolean commitTranslog, boolean force, boolean waitIfOngo
throw new FlushNotAllowedEngineException(shardId, "recovery is in progress, flush is not allowed");
}

if (flushNeeded || force) {
flushNeeded = false;
if (indexWriter.hasUncommittedChanges() || force) {
try {
long translogId = translogIdGenerator.incrementAndGet();
translog.newTransientTranslog(translogId);
Expand Down