-
Couldn't load subscription status.
- Fork 3.4k
HBASE-26987 The length of compact queue grows too big when the compac… #4390
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
base: master
Are you sure you want to change the base?
Changes from all commits
cdc19ba
63bf30f
21afc5f
19349b7
99c38ad
24b0c01
91f855a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,6 +184,13 @@ public class HStore | |
| // TODO: ideally, this should be part of storeFileManager, as we keep passing this to it. | ||
| private final List<HStoreFile> filesCompacting = Lists.newArrayList(); | ||
|
|
||
| // Compaction LongAdders | ||
| final LongAdder compactionsFinishedCount = new LongAdder(); | ||
| final LongAdder compactionsFailedCount = new LongAdder(); | ||
| final LongAdder compactionNumFilesCompacted = new LongAdder(); | ||
| final LongAdder compactionNumBytesCompacted = new LongAdder(); | ||
| final LongAdder compactionsQueuedCount = new LongAdder(); | ||
|
|
||
| // All access must be synchronized. | ||
| private final Set<ChangedReadersObserver> changedReaderObservers = | ||
| Collections.newSetFromMap(new ConcurrentHashMap<ChangedReadersObserver, Boolean>()); | ||
|
|
@@ -1592,7 +1599,8 @@ public void cancelRequestedCompaction(CompactionContext compaction) { | |
| } | ||
|
|
||
| private void finishCompactionRequest(CompactionRequestImpl cr) { | ||
| this.region.reportCompactionRequestEnd(cr.isMajor(), cr.getFiles().size(), cr.getSize()); | ||
| this.region.reportCompactionRequestEnd(cr.isMajor()); | ||
| reportCompactionRequestEnd(cr.getFiles().size(), cr.getSize()); | ||
| if (cr.isOffPeak()) { | ||
| offPeakCompactionTracker.set(false); | ||
| cr.setOffPeak(false); | ||
|
|
@@ -2065,6 +2073,22 @@ public void abort() throws IOException { | |
|
|
||
| @Override | ||
| public boolean needsCompaction() { | ||
| // For some system compacting, we set selectNow to false, and the files do not | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I do not fully understand what is the problem here... The problem is we schedule too many compactions, because of how we know whether there is a compaction running is through the filesCompacting? This is only true for system compaction? Then why not change the logic of requesting system compaction? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current logic is an improvement introduced by HBASE-8665, which could get better store file selection. |
||
| // be selected until compaction runs, so we should limit the compaction count here | ||
| // to avoid the length of queue grows too big. | ||
| int filesNotCompacting = | ||
| this.storeEngine.storeFileManager.getStorefileCount() - filesCompacting.size(); | ||
| int maxFilesToCompact = this.storeEngine.getCompactionPolicy().getConf().getMaxFilesToCompact(); | ||
| int maxCompactionsShouldBeQueued = filesNotCompacting / maxFilesToCompact; | ||
| maxCompactionsShouldBeQueued += filesNotCompacting % maxFilesToCompact == 0 ? 0 : 1; | ||
| if (this.compactionsQueuedCount.sum() >= maxCompactionsShouldBeQueued) { | ||
| LOG.debug( | ||
| "this store has too many compactions in queue, filesNotCompacting:{}, " | ||
| + "compactionsQueuedCount:{}, maxCompactionsNeedQueued:{}", | ||
| filesNotCompacting, this.compactionsQueuedCount.sum(), maxCompactionsShouldBeQueued); | ||
| return false; | ||
| } | ||
|
|
||
| List<HStoreFile> filesCompactingClone = null; | ||
| synchronized (filesCompacting) { | ||
| filesCompactingClone = Lists.newArrayList(filesCompacting); | ||
|
|
@@ -2471,4 +2495,47 @@ public long getBloomFilterNegativeResultsCount() { | |
| public long getBloomFilterEligibleRequestsCount() { | ||
| return storeEngine.getBloomFilterMetrics().getEligibleRequestsCount(); | ||
| } | ||
|
|
||
| public void incrementCompactionsQueuedCount() { | ||
| compactionsQueuedCount.increment(); | ||
| } | ||
|
|
||
| public void decrementCompactionsQueuedCount() { | ||
| compactionsQueuedCount.decrement(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getCompactionsFinishedCount() { | ||
| return this.compactionsFinishedCount.sum(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getCompactionsFailedCount() { | ||
| return this.compactionsFailedCount.sum(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getCompactionsNumFiles() { | ||
| return this.compactionNumFilesCompacted.sum(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getCompactionsNumBytes() { | ||
| return this.compactionNumBytesCompacted.sum(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getCompactionsQueuedCount() { | ||
| return this.compactionsQueuedCount.sum(); | ||
| } | ||
|
|
||
| public void reportCompactionRequestFailure() { | ||
| compactionsFailedCount.increment(); | ||
| } | ||
|
|
||
| public void reportCompactionRequestEnd(int numFiles, long filesSizeCompacted) { | ||
| compactionsFinishedCount.increment(); | ||
| compactionNumFilesCompacted.add(numFiles); | ||
| compactionNumBytesCompacted.add(filesSizeCompacted); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit strange that we only move this field to HStore but still keep other compaction related metrics in HRegion...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right, i thought about it too, but did not find a better way, maybe all that metrics should be moved to HStore?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think moving compaction metrics to HStore would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can move the other compaction metrics in a follow-on issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then is it possible to not include the metrics moving but still fix the problem here? It is not a good idea to land a half done work, so I prefer either we do not move any of them, or move them all at once.