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][ml] Make mlOwnershipChecker asynchronous so that it doesn't block/deadlock threads #21333

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Oct 9, 2023

Motivation

There's a synchronous method that is called from a thread which shouldn't be blocked. This happens in ManagedCursorImpl.persistPositionMetaStore method when the blocking ledger.mlOwnershipChecker.get() call is made. mlOwnershipChecker was introduced in #5604 and perhaps at that time, the method never blocked. This has changed and for example the flaky test #20157 has shown that this blocking happens in practice and causes deadlocks as reported in #21332.

Modifications

  • change the existing Supplier<Boolean> mlOwnershipChecker to an asynchronous Supplier<CompletableFuture<Boolean>> mlOwnershipChecker
  • fix a race condition in ManagedCursorImpl.persistPositionMetaStore so that the callback for the top level method isn't called before the refreshing has occured.

Documentation

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

@lhotari
Copy link
Member Author

lhotari commented Oct 9, 2023

@Demogorgon314 I wonder if this change would help also with the deadlock that you are fixing with #21332.

@Demogorgon314
Copy link
Member

@lhotari I think we still need #21332 because it is another issue.

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.

@lhotari lhotari merged commit eb9fa63 into apache:master Oct 11, 2023
47 checks passed
vinayakmalik95 pushed a commit to tmdc-io/pulsar that referenced this pull request Oct 12, 2023
@heesung-sn
Copy link
Contributor

@lhotari do you think we should back-port this to earlier branches?

heesung-sn pushed a commit that referenced this pull request Feb 28, 2024
heesung-sn pushed a commit that referenced this pull request Feb 28, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 1, 2024
…ck/deadlock threads (apache#21333)

(cherry picked from commit eb9fa63)
(cherry picked from commit 750547b)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 6, 2024
…ck/deadlock threads (apache#21333)

(cherry picked from commit eb9fa63)
(cherry picked from commit 750547b)
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

7 participants