Skip to content

[fix][broker] Fix PulsarService.closeAsync where Condition.signalAll was called without holding a lock - #25777

Merged
lhotari merged 3 commits into
apache:masterfrom
zhaizhibo:fix_broker_close
May 15, 2026
Merged

lhotari merged 3 commits into
apache:masterfrom
zhaizhibo:fix_broker_close

Conversation

@zhaizhibo

Copy link
Copy Markdown
Contributor

Motivation

In PulsarService.closeAsync(), the closeFuture.handle() callback calls isClosedCondition.signalAll() without acquiring the associated mutex lock.

Modifications

  • Fix: Wrap isClosedCondition.signalAll() inside mutex.lock()/unlock() in the closeFuture.handle() callback.
  • Test: Add testWaitUntilClosedConcurrentWithCloseAsync in PulsarServiceCloseTest that calls waitUntilClosed() concurrently with closeAsync().

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

@zhaizhibo

Copy link
Copy Markdown
Contributor Author

@merlimat Fixed.

@zhaizhibo
zhaizhibo requested a review from merlimat May 15, 2026 00:19
@dao-jun dao-jun added area/broker type/bug The PR fixed a bug or issue reported a bug ready-to-test labels May 15, 2026
@lhotari lhotari changed the title [BUG] Fix Condition.signalAll called without holding lock. [fix][broker] Fix PulsarService.closeAsync where Condition.signalAll was called without holding a lock May 15, 2026
@lhotari lhotari added this to the 5.0.0-M1 milestone May 15, 2026

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, good catch! This explains some flakiness that has been related to PulsarService.closeAsync in tests.

@lhotari
lhotari merged commit a200088 into apache:master May 15, 2026
44 checks passed
@zhaizhibo
zhaizhibo deleted the fix_broker_close branch May 15, 2026 10:08
lhotari pushed a commit that referenced this pull request May 18, 2026
…was called without holding a lock (#25777)

Co-authored-by: zhaizhibo <[email protected]>
(cherry picked from commit a200088)
lhotari pushed a commit that referenced this pull request May 18, 2026
…was called without holding a lock (#25777)

Co-authored-by: zhaizhibo <[email protected]>
(cherry picked from commit a200088)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request May 27, 2026
…was called without holding a lock (apache#25777)

Co-authored-by: zhaizhibo <[email protected]>
(cherry picked from commit a200088)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 9, 2026
…was called without holding a lock (apache#25777)

Co-authored-by: zhaizhibo <[email protected]>
(cherry picked from commit a200088)
(cherry picked from commit 7a9b5c7)
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.

5 participants