-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[improve][broker] Enhance compaction triggering with message check to avoid unnecessary operations #24449
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?
Conversation
…k to avoid unnecessary operations
public synchronized CompletableFuture<Void> triggerCompactionWithCheckHasMoreMessages() { | ||
return getLastDispatchablePosition().thenCombine(topicCompactionService.getLastCompactedPosition(), | ||
(lastDispatchablePosition, lastCompactedPosition) -> { | ||
return lastCompactedPosition == null || lastDispatchablePosition.compareTo(lastCompactedPosition) > 0; |
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 lastDispatchablePosition might be null, so need to add null check to prevent NPE
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.
fix
I'm wondering does |
if |
OK, I get it, thank you, now LGTM |
Motivation
If no more message need to compact, then we should skip compaction task
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: