[fix] Avoid resource leakage of AckGroupingTracker#185
Merged
BewareMyPower merged 3 commits intoapache:mainfrom Feb 7, 2023
Merged
[fix] Avoid resource leakage of AckGroupingTracker#185BewareMyPower merged 3 commits intoapache:mainfrom
BewareMyPower merged 3 commits intoapache:mainfrom
Conversation
6c498bf to
1daf3fe
Compare
Contributor
|
I observed a similar bug long days ago: apache/pulsar#8914. This PR might also fix that problem. The |
lib/AckGroupingTrackerEnabled.h
Outdated
| Ready, | ||
| Closed, | ||
| }; | ||
| std::atomic<State> state_; |
Contributor
There was a problem hiding this comment.
The NotStarted and Closed states are never used, would it better to just use a atomic_bool here?
Contributor
Author
There was a problem hiding this comment.
Using similar state definition style is a first thought and it can use atomic_bool isClosed_ instead. May be more explicit. I can change to isClosed style latter.
Contributor
Author
There was a problem hiding this comment.
Updated to isClosed style.
Contributor
|
There might be something wrong with the Vcpkg installation, I will investigate the reason soon. |
shibd
requested changes
Feb 6, 2023
shibd
approved these changes
Feb 6, 2023
BewareMyPower
approved these changes
Feb 7, 2023
4 tasks
BewareMyPower
pushed a commit
that referenced
this pull request
Feb 8, 2023
(cherry picked from commit 0631e36)
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
Avoid resource leakage of AckGroupingTracker.
The result of AckGroupingTracker leakage is waste of cpu. In our case, after a large number (30w+) of consumer creation failures, pulsar client io threads use 99% cpu when no operations.
There are two problems about the leakage:
Modifications
Verifying this change
Can verify this change by adding a log and using a test program. The leakage resources are hold in boost::asio::io_service and seems not easy to write a unit test to verify.
The test program trys to trigger AckGroupingTracker leakage. If there is a leak, will print a lot of test log 'reschedule AckGroupingTrackerEnabled'.
Add a test log:
Test program:
Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-neededBug fix only.
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)