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

[Broker] Avoid thread deadlock problem when creating topic policy reader #13837

Conversation

gaoran10
Copy link
Contributor

@gaoran10 gaoran10 commented Jan 19, 2022

Motivation

Currently, the topic policy reader creation thread is the executor of the PulsarService, this thread is also used to search the candidate broker. If they use the same thread in some conditions, the lookup request will be blocked and result in a lookup request timeout.

image

image

We could find out that the lookup request was blocked 1 minute until the lookup request timeout. The thread pulsar-2-8 was blocked by topic policy reader creation.

Modifications

Change the topic policy reader creation to be asynchronous. Modify the method RetryUtil.retryAsynchronously to handle asynchronous execution.

Verifying this change

Add a new test to verify consumer creations can be successful when enabling the topic policy feature.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below or label this PR directly (if you have committer privilege).

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@codelipenghui codelipenghui added this to the 2.10.0 milestone Jan 19, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 19, 2022
@codelipenghui codelipenghui merged commit 760bfec into apache:master Jan 20, 2022
codelipenghui pushed a commit that referenced this pull request Jan 20, 2022
…der (#13837)

Currently, the topic policy reader creation thread is the `executor` of the `PulsarService`, this thread is also used to search the candidate broker. If they use the same thread in some conditions, the lookup request will be blocked and result in a lookup request timeout.

![image](https://user-images.githubusercontent.com/15029908/150124902-c4318182-56f2-4b31-9149-ae64a9919aa4.png)

![image](https://user-images.githubusercontent.com/15029908/150124952-66a9f095-bab2-40fa-9370-76d3f2158dac.png)

We could find out that the lookup request was blocked 1 minute until the lookup request timeout. The thread `pulsar-2-8` was blocked by topic policy reader creation.

Change the topic policy reader creation to be asynchronous. Modify the method `RetryUtil.retryAsynchronously` to handle asynchronous execution.

Add a new test to verify consumer creations can be successful when enabling the topic policy feature.

(cherry picked from commit 760bfec)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jan 20, 2022
@gaoran10 gaoran10 deleted the gaoran/fix-sync-reader-creation-topic-policies branch January 20, 2022 14:47
codelipenghui pushed a commit that referenced this pull request Jan 21, 2022
…der (#13837)

Currently, the topic policy reader creation thread is the `executor` of the `PulsarService`, this thread is also used to search the candidate broker. If they use the same thread in some conditions, the lookup request will be blocked and result in a lookup request timeout.

![image](https://user-images.githubusercontent.com/15029908/150124902-c4318182-56f2-4b31-9149-ae64a9919aa4.png)

![image](https://user-images.githubusercontent.com/15029908/150124952-66a9f095-bab2-40fa-9370-76d3f2158dac.png)

We could find out that the lookup request was blocked 1 minute until the lookup request timeout. The thread `pulsar-2-8` was blocked by topic policy reader creation.

Change the topic policy reader creation to be asynchronous. Modify the method `RetryUtil.retryAsynchronously` to handle asynchronous execution.

Add a new test to verify consumer creations can be successful when enabling the topic policy feature.

(cherry picked from commit 760bfec)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.3 release/2.9.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants