-
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
fix potential deadlock that can occur in addConsumer #5371
fix potential deadlock that can occur in addConsumer #5371
Conversation
retest this please |
rerun java8 tests |
Do we need to modify other dispatchers (such as |
@massakam good suggestion! Will make to change PersistentDispatcherSingleActiveConsumer as well. |
can you add stacktrace where you have observed deadlock. |
.getDataIfPresent(AdminResource.path(POLICIES, TopicName.get(topic.getName()).getNamespace())); | ||
|
||
if (policies == null) { | ||
policies = new Policies(); |
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.
We should just return false instead of creating empty object.
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.
@rdhabalia I don't think that is correct because we still have to check serviceConfig.getMaxConsumersPerTopic() here:
https://github.com/apache/pulsar/pull/5371/files#diff-5cc001bf2b64aad097762e99c5b78e4aR171
Many threads in the ForkJoinPool are waiting for lock 0x000000068e2dec90 that is locked by the above thread |
Full jstack: |
rerun integration tests |
rerun integration tests |
rerun integration tests |
2 similar comments
rerun integration tests |
rerun integration tests |
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.
👍
* fix potential deadlock that can occur in addConsumer * add fix to PersistentDispatcherSingleActiveConsumer * fixing tests (cherry picked from commit 590b068)
Motivation
We have observed a deadlock that happens when consumers are added because isConsumersExceededOnTopic and isConsumersExceededOnSubscription are blocking calls even though addConsumer is called in async fashion
Modifications
Make the calls isConsumersExceededOnTopic and isConsumersExceededOnSubscription nonblocking by only getting the data from cache and not going to ZK. There can be instances when the data is stale but it should be rare since the data is like already in cache. The more permanent solution would be to make those calls async and addConsumer async but that requires a big change. We are currently in the process of refactoring the MetadataStore interfaces so lets hold off on those big changes until that process is done.