Skip to content

ZOOKEEPER-4979: Provide Metric for Maximum Ephemeral Node Path Length… - #2472

Open
ikxeno wants to merge 1 commit into
apache:masterfrom
ikxeno:ZOOKEEPER-4979
Open

ikxeno wants to merge 1 commit into
apache:masterfrom
ikxeno:ZOOKEEPER-4979

Conversation

@ikxeno

@ikxeno ikxeno commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Problem

When a session owns many ephemeral znodes, the path list in its closeSession transaction can exceed jute.maxbuffer. The existing ephemerals_count exposes the server-wide node count, but gives no indication of the path bytes owned by one session.

Fix

Add max_session_ephemeral_path_bytes, the largest total size of full ephemeral paths owned by one session on the server, measured in UTF-8 bytes. The value decreases after deletion or session closure and returns to zero when no ephemeral nodes remain. It counts path bytes; serialized transactions also contain length prefixes and headers.

  • DataTree caches a byte total for each session and updates it when ephemeral paths are added or removed. Reading the gauge takes O(S) time and the cache adds O(S) memory, where S is the number of tracked session records.
  • Snapshot loading clears the old ephemeral records and rebuilds the totals. The gauge reads the current database and tree on each scrape, so it stays current after restore or database replacement.
  • The gauge is available through Prometheus and AdminServer monitor, and as zk_max_session_ephemeral_path_bytes through mntr. The monitoring and command references document its meaning and serialization overhead, marked new in 3.10.0.

Tests

  • DataTreeTest checks the maximum across sessions, UTF-8 boundaries, duplicate creation, deletion and session closure. It also checks snapshot reloads and that persistent, container and TTL nodes do not affect the total.
  • ZooKeeperServerTest checks gauge registration and removal, and reads after database or tree replacement.
  • CommandsTest.testMonitorMaxSessionEphemeralPathBytes checks the exported value with a real client.

All 56 selected tests passed, including ZookeeperServerRestoreTest, as did Java Checkstyle. The tests detected all 26 targeted source mutations. I also checked Prometheus, AdminServer and mntr locally with two sessions and Unicode paths, including decreases after deletion and session closure.

… per Session

Report the largest total size of ephemeral paths owned by one session
as max_session_ephemeral_path_bytes, measured in UTF-8 bytes. This helps
estimate closeSession transaction sizes relative to jute.maxbuffer.

Cache session totals and update them as nodes are added or removed.
Rebuild the totals when loading a snapshot and collect the gauge from
the current tree so restore and database replacement use current values.

Add tests for UTF-8 boundaries and session lifecycle, and document the
metric in the monitoring and command references.
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.

1 participant