Skip to content

Commit

Permalink
timing
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Feb 14, 2019
1 parent 70e5a72 commit 8d95f3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,15 @@ public IndexResult index(Index index) throws IOException {
new IndexVersionValue(translogLocation, plan.versionForIndexing, plan.seqNoForIndexing, index.primaryTerm()));
}
if (indexResult.getSeqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO) {
if (indexResult.getSeqNo() == 1L) {
// delay the advancement of the local checkpoint so "shouldPeriodicallyFlush" can be true twice
// (1) when two uncommitted operations are in translog and (2) when the local checkpoint is advanced to 1L.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
localCheckpointTracker.markSeqNoAsCompleted(indexResult.getSeqNo());
}
indexResult.setTook(System.nanoTime() - index.startTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2795,6 +2795,11 @@ public Translog.Durability getTranslogDurability() {
*/
public void afterWriteOperation() {
if (shouldPeriodicallyFlush() || shouldRollTranslogGeneration()) {
try {
Thread.sleep(100); // Waits for the first flush to finish
} catch (InterruptedException e) {
throw new AssertionError(e);
}
if (flushOrRollRunning.compareAndSet(false, true)) {
/*
* We have to check again since otherwise there is a race when a thread passes the first check next to another thread which
Expand Down

0 comments on commit 8d95f3a

Please sign in to comment.