-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] PIP-442: Add memory limits for topic list watcher (part 2) #25070
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #25070 +/- ##
=============================================
+ Coverage 37.48% 72.55% +35.07%
- Complexity 13220 34266 +21046
=============================================
Files 1899 1956 +57
Lines 150586 154897 +4311
Branches 17159 17661 +502
=============================================
+ Hits 56440 112392 +55952
+ Misses 86464 33505 -52959
- Partials 7682 9000 +1318
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Denovo1998
left a comment
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.
Left some comments.
...g/apache/pulsar/client/api/PatternConsumerTopicWatcherBackPressureMultipleConsumersTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Outdated
Show resolved
Hide resolved
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.
Pull request overview
This PR implements memory limits for topic list watcher operations as part of PIP-442. It introduces backpressure mechanisms to prevent broker memory exhaustion when handling concurrent pattern consumer topic list requests by applying memory limiting to topic list watcher creation and update operations.
Key Changes
- Added memory limit acquisition with retry logic for topic list watcher initialization and updates
- Modified topic list watcher to queue updates during initialization to avoid race conditions
- Enhanced test coverage for memory limiting scenarios and concurrent consumer patterns
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar-common/src/main/java/org/apache/pulsar/common/semaphore/AsyncSemaphoreImpl.java | Added toString method to SemaphorePermit for debugging |
| pulsar-common/src/main/java/org/apache/pulsar/common/semaphore/AsyncDualMemoryLimiterImpl.java | Added toString method to DualMemoryLimiterPermit for debugging |
| pulsar-broker/src/test/java/org/apache/pulsar/client/api/PatternConsumerTopicWatcherBackPressureMultipleConsumersTest.java | New test validating backpressure with 100 concurrent pattern consumers and 300 topics |
| pulsar-broker/src/test/java/org/apache/pulsar/broker/service/TopicListWatcherTest.java | Updated test setup to use direct executor and verify watcher initialization completion |
| pulsar-broker/src/test/java/org/apache/pulsar/broker/service/TopicListServiceTest.java | Added comprehensive tests for permit acquisition retries and memory limiting scenarios |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java | Implemented memory limiting with retry backoff for watcher operations and queued updates during initialization |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java | Modified methods to acquire direct memory permits before sending topic list messages |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSender.java | Updated interface to return CompletableFuture and accept error handler for permit acquisition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/TopicListServiceTest.java
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Denovo1998
left a comment
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.
@lhotari It seems it will still be out of order.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Show resolved
Hide resolved
Denovo1998
left a comment
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.
The problem of scrambling seems to have been solved for now.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
Outdated
Show resolved
Hide resolved
|
Overall LGTM except for my comments |
PIP-442
Motivation
See PIP-442.
This is part 2 for the PIP-442 implementation. This covers the topic list watcher operations.
The first part of PIP-442 implementation was #24833.
This PR implements memory limits and flow control for the
CommandWatchTopicListfeature as specified in PIP-442. Currently, topic list watcher operations can allocate unbounded amounts of memory based on namespace size, creating the final significant gap in Pulsar's otherwise comprehensive memory management system.The lack of memory limits creates several critical issues:
This PR completes Pulsar's memory management framework by implementing memory-based flow control and backpressure specifically for topic list watcher operations.
Modifications
sendWatchTopicListSuccessandsendWatchTopicListUpdatemethods to returnCompletableFuture<Void>and accept permit acquire error handlers for asynchronous memory managementPatternConsumerTopicWatcherBackPressureMultipleConsumersTestto verify backpressure behavior with multiple concurrent consumersTopicListServiceTestandTopicListWatcherTestto accommodate the new asynchronous response patternDocumentation
docdoc-requireddoc-not-neededdoc-complete