[improve][broker] Add http produce backlog quota check#25189
Open
Dream95 wants to merge 1 commit intoapache:masterfrom
Open
[improve][broker] Add http produce backlog quota check#25189Dream95 wants to merge 1 commit intoapache:masterfrom
Dream95 wants to merge 1 commit intoapache:masterfrom
Conversation
Denovo1998
suggested changes
Jan 29, 2026
Contributor
Denovo1998
left a comment
There was a problem hiding this comment.
Now it does a backlog quota check for each message, maybe it can be optimized?
- In internalPublishMessages(...), first calculate which partition(s) the current request will write to (actually, you have already calculated in round-robin which partition each message goes to).
- Perform once for each partition:
- getTopic(partitionTopic)
- checkBacklogQuotaExceeded(...destination_storage + message_age)
- After all checks pass, then enter the actual publish loop
- If the check for a certain partition fails: mark all the message results corresponding to that partition as failed (no longer attempt to publish), other partitions can continue.
Comment on lines
288
to
291
| topicObj.checkBacklogQuotaExceeded(defaultProducerName, | ||
| BacklogQuota.BacklogQuotaType.destination_storage), | ||
| topicObj.checkBacklogQuotaExceeded(defaultProducerName, | ||
| BacklogQuota.BacklogQuotaType.message_age)); |
Contributor
There was a problem hiding this comment.
Should we pass in message.getProducerName(); here?
| if (log.isDebugEnabled()) { | ||
| log.debug("Fail to publish single messages to topic {}: {} ", | ||
| topicName, e.getCause()); | ||
| log.debug("Fail to publish single message to topic {}: {}", topic, ex.getMessage()); |
Contributor
There was a problem hiding this comment.
Here you can first use FutureUtil.unwrapCompletionException.
| .topic(topicName) | ||
| .create(); | ||
| producer.send("backlog-message"); | ||
| Thread.sleep(2000); |
Contributor
There was a problem hiding this comment.
Perhaps it can be replaced with a "poll until quota exceeded (with timeout)" method.
- Add http produce backlog quota check for both destination_storage and message_age Signed-off-by: Dream95 <zhou_8621@163.com>
ed77c82 to
339a6b8
Compare
Contributor
Author
|
@Denovo1998 Thank you for your review. I have solved the problems you mentioned.Regarding the optimiz,per-message checks are more precise? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The binary protocol already performs check backlog quota in
ServerCnxwhen creating producers, but the HTTP REST API path was missing this validation.Modifications
publishSingleMessageToPartitionmethod for bothdestination_storageandmessage_agequota typesThe implementation follows the same pattern used in
ServerCnx.handleProducerwhere backlog quota checks are performed before allowing message production.Verifying this change
This change is already covered by existing tests, such as:
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Changes to REST endpoints:
/persistent/{tenant}/{namespace}/{topic}/partitions/{partition}) now properly enforces backlog quota limits before publishing messages. When backlog quota is exceeded, the request will fail with an appropriate error, consistent with the binary protocol behavior.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: Dream95#4