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

[fix][broker] Fix a deadlock in SystemTopicBasedTopicPoliciesService during NamespaceEventsSystemTopicFactory init #22528

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

heesung-sn
Copy link
Contributor

Motivation

Found a deadlock case in SystemTopicBasedTopicPoliciesService during NamespaceEventsSystemTopicFactory init

Deadlock case

"thread-1":
t1: prepareInitPoliciesCacheAsync(SystemTopicBasedTopicPoliciesService.java:338) (acquired the `policyCacheInitMap` lock)

t2: createSystemTopicFactoryIfNeeded(SystemTopicBasedTopicPoliciesService.java:599) (waiting for the `synchronized (this)` lock)


"thread-2":
t1: addOwnedNamespaceBundleAsync(SystemTopicBasedTopicPoliciesService.java:322) (acquired the `synchronized (this)` lock

t2: prepareInitPoliciesCacheAsync(SystemTopicBasedTopicPoliciesService.java:338) (waiting for the `policyCacheInitMap` lock)

Modifications

  • Use a separate lock for the singleton NamespaceEventsSystemTopicFactory init by org.apache.commons.lang3.concurrent.LazyInitializer.

Verifying this change

  • Make sure that the change passes the CI checks.

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

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 18, 2024
@heesung-sn heesung-sn self-assigned this Apr 18, 2024
@heesung-sn heesung-sn added this to the 3.3.0 milestone Apr 18, 2024
Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. and it looks like the synchronized in addOwnedNamespaceBundleAsync method is useless now?

@heesung-sn
Copy link
Contributor Author

it looks like the synchronized in addOwnedNamespaceBundleAsync method is useless now?

I think it is used to additionally synchronize the current access of addOwnedNamespaceBundleAsync.

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good work @heesung-sn !

@lhotari lhotari merged commit 72474d7 into apache:master Apr 18, 2024
71 of 75 checks passed
lhotari pushed a commit that referenced this pull request Apr 18, 2024
…during NamespaceEventsSystemTopicFactory init (#22528)

(cherry picked from commit 72474d7)
lhotari pushed a commit that referenced this pull request Apr 18, 2024
…during NamespaceEventsSystemTopicFactory init (#22528)

(cherry picked from commit 72474d7)
lhotari pushed a commit that referenced this pull request Apr 18, 2024
…during NamespaceEventsSystemTopicFactory init (#22528)

(cherry picked from commit 72474d7)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 19, 2024
…during NamespaceEventsSystemTopicFactory init (apache#22528)

(cherry picked from commit 72474d7)
(cherry picked from commit 404bcdf)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 23, 2024
…during NamespaceEventsSystemTopicFactory init (apache#22528)

(cherry picked from commit 72474d7)
(cherry picked from commit 404bcdf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants