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
commented
Nov 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
…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
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 21, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|