-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Broker] Fix set-publish-rate when using preciseTopicPublishRateLimiterEnable=true #10384
[Broker] Fix set-publish-rate when using preciseTopicPublishRateLimiterEnable=true #10384
Conversation
@aloyszhang @codelipenghui @merlimat @eolivelli Please review. I'd also like to get some help in resolving the open issue described in the PR description. |
@aloyszhang @codelipenghui @merlimat @eolivelli I'd appreciate your feedback on this PR Please review. @aloyszhang |
...-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java
Show resolved
Hide resolved
@codelipenghui @merlimat @rdhabalia do you have any comment ? |
Sorry for the late. |
@aloyszhang Is it so that it should be called in both cases, but it's some kind of optimization to skip calling it for the other case? |
a9826bd
to
ac41481
Compare
@lhotari Yes, since the |
It seems that the rate limiting should be somehow combined when both limits |
@lhotari Yes, inconsistent between |
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.
LGTM
@sijie @aloyszhang @codelipenghui I have rebased the changes. Please review this PR and #11442 . There are other PRs #11352 and #11372 that depend on these changes so it would be good to get this PR processed asap. Thanks! |
…RateLimiterEnable=true - disabling the limit didn't work after setting a limit because of a bug in PrecisPublishLimiter
9ffaa2d
to
c8aa9d2
Compare
@sijie @aloyszhang @codelipenghui Please review. The changes have been rebased. |
Thank you for taking care of this. LGTM. |
…erEnable=true (apache#10384) ### Motivation When using `preciseTopicPublishRateLimiterEnable=true` (introduced by apache#7078) setting for rate limiting, there are various issues: - updating the limits doesn't set either boundary when changing the limits from a bounded limit to unbounded. - each topic will create a scheduler thread for each limiter instance - each topic will never release the scheduler thread when the topic gets unloaded / closed - updating the limits didn't close the scheduler thread related to the replaced limiter instance ### Modifications - Fix updating of the limits by cleaning up the previous limiter instances before creating new limiter instances - Use `brokerService.pulsar().getExecutor()` as the scheduler for the rate limiter instances - Add resource cleanup hooks for topic closing (unload) ### Open issue The existing code has a difference in passing the `rateLimitFunction`: https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java#L80-L86 It's passed to the `topicPublishRateLimiterOnMessage`, but not to `topicPublishRateLimiterOnByte` . It is unclear whether this is intentional. The `rateLimitFunction` is `() -> this.enableCnxAutoRead()` https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L913 (This also raises a question whether rate limiting works consistently when multiple topics share the same connection.)
…erEnable=true (#10384) ### Motivation When using `preciseTopicPublishRateLimiterEnable=true` (introduced by #7078) setting for rate limiting, there are various issues: - updating the limits doesn't set either boundary when changing the limits from a bounded limit to unbounded. - each topic will create a scheduler thread for each limiter instance - each topic will never release the scheduler thread when the topic gets unloaded / closed - updating the limits didn't close the scheduler thread related to the replaced limiter instance ### Modifications - Fix updating of the limits by cleaning up the previous limiter instances before creating new limiter instances - Use `brokerService.pulsar().getExecutor()` as the scheduler for the rate limiter instances - Add resource cleanup hooks for topic closing (unload) ### Open issue The existing code has a difference in passing the `rateLimitFunction`: https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java#L80-L86 It's passed to the `topicPublishRateLimiterOnMessage`, but not to `topicPublishRateLimiterOnByte` . It is unclear whether this is intentional. The `rateLimitFunction` is `() -> this.enableCnxAutoRead()` https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L913 (This also raises a question whether rate limiting works consistently when multiple topics share the same connection.) (cherry picked from commit ded806f)
…erEnable=true (#10384) When using `preciseTopicPublishRateLimiterEnable=true` (introduced by #7078) setting for rate limiting, there are various issues: - updating the limits doesn't set either boundary when changing the limits from a bounded limit to unbounded. - each topic will create a scheduler thread for each limiter instance - each topic will never release the scheduler thread when the topic gets unloaded / closed - updating the limits didn't close the scheduler thread related to the replaced limiter instance - Fix updating of the limits by cleaning up the previous limiter instances before creating new limiter instances - Use `brokerService.pulsar().getExecutor()` as the scheduler for the rate limiter instances - Add resource cleanup hooks for topic closing (unload) The existing code has a difference in passing the `rateLimitFunction`: https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java#L80-L86 It's passed to the `topicPublishRateLimiterOnMessage`, but not to `topicPublishRateLimiterOnByte` . It is unclear whether this is intentional. The `rateLimitFunction` is `() -> this.enableCnxAutoRead()` https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L913 (This also raises a question whether rate limiting works consistently when multiple topics share the same connection.) (cherry picked from commit ded806f)
…erEnable=true (apache#10384) When using `preciseTopicPublishRateLimiterEnable=true` (introduced by apache#7078) setting for rate limiting, there are various issues: - updating the limits doesn't set either boundary when changing the limits from a bounded limit to unbounded. - each topic will create a scheduler thread for each limiter instance - each topic will never release the scheduler thread when the topic gets unloaded / closed - updating the limits didn't close the scheduler thread related to the replaced limiter instance - Fix updating of the limits by cleaning up the previous limiter instances before creating new limiter instances - Use `brokerService.pulsar().getExecutor()` as the scheduler for the rate limiter instances - Add resource cleanup hooks for topic closing (unload) The existing code has a difference in passing the `rateLimitFunction`: https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java#L80-L86 It's passed to the `topicPublishRateLimiterOnMessage`, but not to `topicPublishRateLimiterOnByte` . It is unclear whether this is intentional. The `rateLimitFunction` is `() -> this.enableCnxAutoRead()` https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L913 (This also raises a question whether rate limiting works consistently when multiple topics share the same connection.) (cherry picked from commit ded806f) (cherry picked from commit 41ad624)
…erEnable=true (apache#10384) ### Motivation When using `preciseTopicPublishRateLimiterEnable=true` (introduced by apache#7078) setting for rate limiting, there are various issues: - updating the limits doesn't set either boundary when changing the limits from a bounded limit to unbounded. - each topic will create a scheduler thread for each limiter instance - each topic will never release the scheduler thread when the topic gets unloaded / closed - updating the limits didn't close the scheduler thread related to the replaced limiter instance ### Modifications - Fix updating of the limits by cleaning up the previous limiter instances before creating new limiter instances - Use `brokerService.pulsar().getExecutor()` as the scheduler for the rate limiter instances - Add resource cleanup hooks for topic closing (unload) ### Open issue The existing code has a difference in passing the `rateLimitFunction`: https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java#L80-L86 It's passed to the `topicPublishRateLimiterOnMessage`, but not to `topicPublishRateLimiterOnByte` . It is unclear whether this is intentional. The `rateLimitFunction` is `() -> this.enableCnxAutoRead()` https://github.com/apache/pulsar/blob/69a173a82c89893f54dbe5b6f422249f66ea5418/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L913 (This also raises a question whether rate limiting works consistently when multiple topics share the same connection.)
Motivation
When using
preciseTopicPublishRateLimiterEnable=true
(introduced by #7078) setting for rate limiting, there are various issues:Modifications
brokerService.pulsar().getExecutor()
as the scheduler for the rate limiter instancesOpen issue
The existing code has a difference in passing the
rateLimitFunction
:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PrecisPublishLimiter.java
Lines 80 to 86 in 69a173a
It's passed to the
topicPublishRateLimiterOnMessage
, but not totopicPublishRateLimiterOnByte
. It is unclear whether this is intentional.The
rateLimitFunction
is() -> this.enableCnxAutoRead()
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
Line 913 in 69a173a
(This also raises a question whether rate limiting works consistently when multiple topics share the same connection.)