Skip to content

Conversation

@hrzzzz
Copy link
Contributor

@hrzzzz hrzzzz commented Aug 12, 2025

Motivation

In the org.apache.pulsar.metadata.impl.ZKMetadataStore class, during initialization and upon receiving the SessionReestablished event from ZooKeeper, a watcher is registered using the following code:

zkc.addWatch("/", this::handleWatchEvent, AddWatchMode.PERSISTENT_RECURSIVE,
        (rc, path, ctx) -> {
            // ...
}, null);

The use of this::handleWatchEvent here causes the watcher passed to the addWatch method not to be the same object each time, which may lead to duplicate registrations.

Modifications

Use the same watcher object when calling the addWatch method

Verifying this change

  • Make sure that the change passes the CI checks.

  • Added test in org.apache.pulsar.metadata.ZKSessionTest#testNoDuplicateWatcherRegistrationAfterSessionReestablished

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: hrzzzz#16

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 12, 2025
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

@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.26%. Comparing base (bbf56f6) to head (cd7226f).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24621      +/-   ##
============================================
- Coverage     74.41%   74.26%   -0.16%     
+ Complexity    33229    32778     -451     
============================================
  Files          1881     1881              
  Lines        146850   146851       +1     
  Branches      16866    16866              
============================================
- Hits         109282   109054     -228     
- Misses        28939    29127     +188     
- Partials       8629     8670      +41     
Flag Coverage Δ
inttests 26.70% <75.00%> (+0.08%) ⬆️
systests 23.31% <50.00%> (-0.12%) ⬇️
unittests 73.74% <100.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...g/apache/pulsar/metadata/impl/ZKMetadataStore.java 86.06% <100.00%> (+0.04%) ⬆️

... and 91 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhotari lhotari merged commit e7fe889 into apache:master Aug 14, 2025
101 of 103 checks passed
lhotari pushed a commit that referenced this pull request Aug 14, 2025
…lished (#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
lhotari pushed a commit that referenced this pull request Aug 14, 2025
…lished (#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
lhotari pushed a commit that referenced this pull request Aug 14, 2025
…lished (#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
(cherry picked from commit b8e0718)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
(cherry picked from commit b8e0718)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
(cherry picked from commit d874c3e)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 26, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
(cherry picked from commit d874c3e)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 26, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Sep 10, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
(cherry picked from commit e7fe889)
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
…lished (apache#24621)

Co-authored-by: ruihongzhou <ruihongzhou@didiglobal.com>
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.

4 participants