-
Notifications
You must be signed in to change notification settings - Fork 902
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
Fix force GC doesn't work under forceAllowCompaction when disk is full #3205
Fix force GC doesn't work under forceAllowCompaction when disk is full #3205
Conversation
rerun failure checks |
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.
Could we add unit tests?
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.
Looks like it's expected behavior? We have another configuration isForceGCAllowWhenNoSpace
which is used to control the force gc is allowed when no space, maybe you need to set it to true?
@zymap If we set What we need is that the bookie suspend the minor and major compaction when disk usage reaches max threshold, but when we deleted topic or shorten the retention, we trigger GC by rest api, and bookie server neglect the current |
But after your change, it will run the major compaction first, which may lead to the dist exhaust as well and cannot compact the entry, right? |
@zymap In order to keep the original logic, I add two flag for REST API to trigger GC, Please take a look, thanks. |
@nicoloboschi I have added the unit test, please take a look, thanks. |
bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java
Outdated
Show resolved
Hide resolved
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CompactionTest.java
Show resolved
Hide resolved
rerun failure checks |
rerun failure checks |
getGCThread().triggerGC(true, true, true).get(); | ||
majorCompactionCntAfterGC = getGCThread().getGarbageCollectionStatus().getMajorCompactionCounter(); | ||
minorCompactionCntAfterGC = getGCThread().getGarbageCollectionStatus().getMinorCompactionCounter(); | ||
if (isForceCompactionAllowWhenDisableCompaction) { |
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.
What's the difference between the if and else? Looks like they are asserting the same thing?
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.
Whether we will enter major or minor compaction is controlled by
((isForceMajorCompactionAllow && force) || (enableMajorCompaction
&& (force || curTime - lastMajorCompactionTime > majorCompactionInterval)))
&& (!suspendMajor)
That is:
isForceMajorCompactionAllow && force
or(enableMajorCompaction && (force || curTime - lastMajorCompactionTime > majorCompactionInterval)
- suspendMajor
We must meet above both conditions.
The if and else is different code path controlled by isForceMajorCompactionAllow && force
and (enableMajorCompaction && (force || curTime - lastMajorCompactionTime > majorCompactionInterval)
apache#3205) ## Motivation When I set `forceAllowCompaction=true` and one ledger disk reaches max usage threshold and transfer bookie to readOnly mode, I expire some pulsar topics or delete some topics to free up disk space. I found that ledger compression cannot be triggered when using `curl -XPUT http://localhost:8000/api/v1/bookie/gc` command. The root cause is that when one ledger disk reaches max usage threshold, it will suspend minor and major compaction https://github.com/apache/bookkeeper/blob/f7579fd13d62ce630ea26638e73f5884da505ec8/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java#L1041-L1058 When we use `curl -XPUT http://localhost:8000/api/v1/bookie/gc` command to trigger compaction, it will be filtered by `suspendMajor` and `suspendMinor` flag. https://github.com/apache/bookkeeper/blob/f7579fd13d62ce630ea26638e73f5884da505ec8/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java#L416-L444 It will lead to - The bookie won't clean up deleted ledgers - Ledger disk can't free up disk usage - Bookie can't recover from readOnly state into Writeable state. And then we can only trigger compaction by the following steps. - Increase max disk usage threshold - Restart the bookie - Use command `curl -XPUT http://localhost:8000/api/v1/bookie/gc` to trigger compaction ### Changes 1. Don't take the `suspendMajor` and `suspendMinor` flag into consideration when setting `forceAllowCompaction=true` and triggered by force GC.
Motivation
When I set
forceAllowCompaction=true
and one ledger disk reaches max usage threshold and transfer bookie to readOnly mode, I expire some pulsar topics or delete some topics to free up disk space. I found that ledger compression cannot be triggered when usingcurl -XPUT http://localhost:8000/api/v1/bookie/gc
command.The root cause is that when one ledger disk reaches max usage threshold, it will suspend minor and major compaction
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
Lines 1041 to 1058 in f7579fd
When we use
curl -XPUT http://localhost:8000/api/v1/bookie/gc
command to trigger compaction, it will be filtered bysuspendMajor
andsuspendMinor
flag.bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
Lines 416 to 444 in f7579fd
It will lead to
And then we can only trigger compaction by the following steps.
curl -XPUT http://localhost:8000/api/v1/bookie/gc
to trigger compactionChanges
suspendMajor
andsuspendMinor
flag into consideration when settingforceAllowCompaction=true
and triggered by force GC.