Skip to content

Commit

Permalink
fix comment after talked to Boaz
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Mar 22, 2018
1 parent a24b434 commit 4240241
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1390,18 +1390,19 @@ public boolean shouldPeriodicallyFlush() {
return false;
}
/*
* We flush to reduce the size of uncommitted translog but strictly speaking the uncommitted size won't always be below
* the threshold after a flush. An endless loop may occur when the uncommitted size is close to the flush threshold,
* the current generation is also close to the generation threshold, and an index is faster and rolls a new generation.
* We flush to reduce the size of uncommitted translog but strictly speaking the uncommitted size won't always be
* below the flush-threshold after a flush. To avoid getting into an endless loop of flushing, we only enable the
* periodically flush condition if this condition is disabled after a flush. The condition will change if the new
* commit points to the later generation the last commit's(eg. gen-of-last-commit < gen-of-new-commit)[1].
*
* Avoid getting into an endless loop of flushing, we only enable the periodically flush condition if this condition is disabled
* after a flush. The condition will change if the new commit points to the later generation the last commit's.
* Or if the local checkpoint equals to max_seqno and translogGenerationOfLastCommit equals to translogGenerationOfNewCommit,
* we know that the last generation must contain operations because its size is above the flush threshold and
* the flush threshold is guaranteed to be higher than an empty translog by the setting validation.
* This guarantees that the new commit will point to the newly rolled generation.
* When the local checkpoint equals to max_seqno, and translog-gen of the last commit equals to translog-gen of
* the new commit, we know that the last generation must contain operations because its size is above the flush
* threshold and the flush-threshold is guaranteed to be higher than an empty translog by the setting validation.
* This guarantees that the new commit will point to the newly rolled generation. In fact, this scenario only
* happens when the generation-threshold is close to or above the flush-threshold; otherwise we have rolled
* generations as the generation-threshold was reached, then the first condition (eg. [1]) is already satisfied.
*
* This method is to maintain translog only, thus the IndexWriter#hasUncommittedChanges condition is not considered.
* This method is to maintain translog only, thus IndexWriter#hasUncommittedChanges condition is not considered.
*/
final long translogGenerationOfNewCommit =
translog.getMinGenerationForSeqNo(localCheckpointTracker.getCheckpoint() + 1).translogFileGeneration;
Expand Down

0 comments on commit 4240241

Please sign in to comment.