Skip to content

ZOOKEEPER-5091: WatchManager reports connections with no active watches after consuming the last standard watch - #2457

Open
casolaroSalvatore wants to merge 1 commit into
apache:masterfrom
casolaroSalvatore:ZOOKEEPER-5091
Open

casolaroSalvatore wants to merge 1 commit into
apache:masterfrom
casolaroSalvatore:ZOOKEEPER-5091

Conversation

@casolaroSalvatore

Copy link
Copy Markdown

Background

When the last STANDARD watch associated with a watcher is triggered, WatchManager removes the path registration but retains an empty entry in watch2Paths. As a result, getWatchesSummary() reports one connection with zero paths and zero watches, while getWatches() reports the session with an empty path set.

Change

Remove the watcher from watch2Paths when its last STANDARD watch is consumed and the associated path map becomes empty. The cleanup is performed only when the path map is empty, so other registrations belonging to the same watcher are preserved.

Testing

Regression tests verify that:

  • the watcher is removed from the watches summary after its last STANDARD watch is consumed;
  • the watcher is no longer included in the connection-oriented watches report;
  • another registration belonging to the same watcher is preserved.

Validation performed locally:

  • Individual regression tests passed.
  • WatchManagerTest passed.
  • Checkstyle passed with 0 violations.
  • SpotBugs passed with 0 errors or warnings.

JIRA: ZOOKEEPER-5091

This issue was identified while working on an academic software testing project provided within a course taught by Prof. Guglielmo De Angelis (@gulyx) at the University of Rome Tor Vergata.

@kezhuw kezhuw 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.

Looks good! Thank you!

@kezhuw

kezhuw commented Sep 18, 2026

Copy link
Copy Markdown
Member

I saw the fix in #612, it did fix the memory leak. But it did not fix the semantics. WatchesSummary.numConnections and WatchesReport.id2paths should only report the currently state but not acculated state since connection established.

@kezhuw
kezhuw requested a review from anmolnar September 18, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants