Skip to content

Commit

Permalink
Only requeue compaction when there was activity (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-turner authored Nov 9, 2018
1 parent 1d35788 commit b6409ef
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ public void run() {
return;
}

tablet.majorCompact(reason, queued);
CompactionStats stats = tablet.majorCompact(reason, queued);

// if there is more work to be done, queue another major compaction
synchronized (tablet) {
if (reason == MajorCompactionReason.NORMAL && tablet.needsMajorCompaction(reason))
tablet.initiateMajorCompaction(reason);
// Some compaction strategies may always return true for shouldCompact() because they need to
// make blocking calls to gather information. Without the following check these strategies would
// endlessly requeue. So only check if a subsequent compaction is needed if the previous
// compaction actually did something.
if (stats != null && stats.getEntriesRead() > 0) {
// if there is more work to be done, queue another major compaction
synchronized (tablet) {
if (reason == MajorCompactionReason.NORMAL && tablet.needsMajorCompaction(reason))
tablet.initiateMajorCompaction(reason);
}
}
}

Expand Down

0 comments on commit b6409ef

Please sign in to comment.