Skip to content
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][broker] Use dispatchRateLimiterLock to update dispatchRateLimiter. #15601

Merged
merged 1 commit into from
May 16, 2022

Conversation

Technoboy-
Copy link
Contributor

Motivation

private void initializeRateLimiterIfNeeded() {
synchronized (dispatchRateLimiter) {
// dispatch rate limiter for topic
if (!dispatchRateLimiter.isPresent()
&& DispatchRateLimiter.isDispatchRateEnabled(topicPolicies.getDispatchRate().get())) {
this.dispatchRateLimiter = Optional.of(new DispatchRateLimiter(this, Type.TOPIC));
}
updateSubscribeRateLimiter();
// dispatch rate limiter for each subscription
subscriptions.forEach((name, subscription) -> {
Dispatcher dispatcher = subscription.getDispatcher();
if (dispatcher != null) {
dispatcher.initializeDispatchRateLimiterIfNeeded();
}
});
// dispatch rate limiter for each replicator
replicators.forEach((name, replicator) ->
replicator.initializeDispatchRateLimiterIfNeeded());
}
}

The object lock may change when execute at line-382, and cause the lock to become useless.

So use dispatchRateLimiterLock to synchronize.

Documentation

  • no-need-doc
    (Please explain why)

@Technoboy- Technoboy- changed the title Use dispatchRateLimiterLock to update dispatchRateLimiter. [fix][broker] Use dispatchRateLimiterLock to update dispatchRateLimiter. May 14, 2022
@Technoboy- Technoboy- self-assigned this May 14, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 14, 2022
@Technoboy- Technoboy- added this to the 2.11.0 milestone May 14, 2022
@codelipenghui codelipenghui added release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug area/broker labels May 14, 2022
@codelipenghui codelipenghui merged commit ff4e600 into apache:master May 16, 2022
mattisonchao pushed a commit that referenced this pull request May 25, 2022
@mattisonchao mattisonchao added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label May 25, 2022
codelipenghui pushed a commit to codelipenghui/incubator-pulsar that referenced this pull request Jun 7, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jun 7, 2022
)

https://github.com/apache/pulsar/blob/58c82a71beb7506e422def391af532945be2b7a7/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L377-L399

The object lock may change when execute at line-382, and cause the lock to become useless.

So use `dispatchRateLimiterLock` to synchronize.

(cherry picked from commit ff4e600)
(cherry picked from commit a5034d6)
@Technoboy- Technoboy- deleted the fix-dispacher-lock branch August 10, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants