AnonHxy opened a new pull request, #15599: URL: https://github.com/apache/pulsar/pull/15599
### Motivation Synchronized update `topicPublishRateLimiter` in case of race condtion. There is a race condtion when two threads update `topicPublishRateLimiter` concurrency: * `topicPublishRateLimiter` is null at the beginning * Thread1 update it with both `publishThrottlingRateInByte < 0` and `publishThrottlingRateInMsg < 0` * Then thread1 stop at https://github.com/apache/pulsar/blob/7bdfa3a3e5e71c44a174b28d0a843fb6730865fa/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L1170 * Thread2 update it with `publishThrottlingRateInByte > 0` or `publishThrottlingRateInMsg > 0` * And thread2 will set `topicPublishRateLimiter` a new limiter. * Then Thread1 resume, and set it to `PublishRateLimiter.DISABLED_RATE_LIMITER`. Then the new limiter setted by thread2 will never be accessed, which will produce resource leakages ### Modifications Synchronized method `updatePublishDispatcher` ### Verifying this change - [x] Make sure that the change passes the CI checks. ### Documentation - [x] `no-need-doc` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
