GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][meta] Fix skipped watch restoration and lock revalidation when probes detect a new ZooKeeper session by void-ptr974 · Pull Request #27620 · apache/pulsar

Conversation

@void-ptr974

@void-ptr974 void-ptr974 commented Nov 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation

This PR restores persistent recursive watches and revalidates all held ephemeral locks when a connection probe detects a writable replacement ZooKeeper session.

These recovery actions can currently be skipped even after the new session connects. A probe can advance the connected handle generation before the metadata event executor processes the old handle's queued Expired event. The expiration is then discarded as stale. If the watcher has not entered SessionLost, it never emits SessionReestablished, which triggers watch restoration and full lock revalidation. When the watcher still considers the session established, SessionLost and Reconnected are also missing.

Modifications

  • Recognize the first writable connection on a newer handle generation as session replacement in the shared probe and watcher transition. Emit SessionLost if needed, followed by Reconnected and SessionReestablished.
  • Commit the new state before invoking listeners, deliver probe notifications after releasing reconnectLock, and suppress delayed expiration events and duplicate connection observations.
  • Add deterministic regression tests for probe-first and watcher-first ordering, with and without a previously processed ConnectionLost. Verify notification order, duplicate suppression, and listener execution outside the handle-update lock.

Verifying this change

All 87 selected tests and :pulsar-metadata:quickCheck pass on Linux with JDK 21, with test retries disabled.

  • ZKSessionWatcherTest, ZKSessionTest, and PulsarZooKeeperClientTest account for 37 passing tests.
  • LockManagerTest accounts for 50 passing tests across ZooKeeper, Memory, RocksDB, Oxia, and MockZooKeeper.

The new regression test reproduces the missing notifications on the original code and passes with the fix.

./gradlew --no-daemon --console=plain --max-workers=4 \
  :pulsar-metadata:quickCheck :pulsar-metadata:test \
  --tests org.apache.pulsar.metadata.LockManagerTest \
  --tests org.apache.pulsar.metadata.impl.ZKSessionWatcherTest \
  --tests org.apache.pulsar.metadata.ZKSessionTest \
  --tests org.apache.pulsar.metadata.impl.PulsarZooKeeperClientTest \
  -PtestRetryCount=0 -PtestMaxParallelForks=1
  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts

  • 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@void-ptr974
[fix][meta] Fix skipped watch restoration and lock revalidation when …
9c6a155
…probes detect a new ZooKeeper session

Treat the first writable connection on a replacement handle as session recovery even when its probe precedes the old handle expiration event. Deliver loss and recovery notifications in order and suppress late duplicates.

Assisted-by: Codex
@void-ptr974
void-ptr974 marked this pull request as draft November 15, 2026 02:42
@void-ptr974
void-ptr974 marked this pull request as ready for review November 15, 2026 02:48
codelipenghui
codelipenghui approved these changes Nov 15, 2026
View reviewed changes
@codelipenghui
codelipenghui merged commit c87f1ad into apache:master Nov 15, 2026
44 of 45 checks passed

Uh oh!

There was an error while loading. Please reload this page.

lhotari pushed a commit that referenced this pull request Nov 17, 2026
@void-ptr974 @lhotari
[fix][meta] Fix skipped watch restoration and lock revalidation when …
5053182
…probes detect a new ZooKeeper session (#27620)

(cherry picked from commit c87f1ad)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Nov 17, 2026
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 release/4.2.6 cherry-picked/branch-4.0 release/4.0.15 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@void-ptr974 @lhotari
[fix][meta] Fix skipped watch restoration and lock revalidation when …
486779d
…probes detect a new ZooKeeper session (apache#27620)

(cherry picked from commit c87f1ad)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@void-ptr974 @lhotari
[fix][meta] Fix skipped watch restoration and lock revalidation when …
c1cc3e5
…probes detect a new ZooKeeper session (apache#27620)

(cherry picked from commit c87f1ad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@codelipenghui codelipenghui codelipenghui approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.0.15 release/4.2.6 release/5.0.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@void-ptr974 @codelipenghui @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.