Skip to content

Backport the recursive snapshot summary tool - #151

Draft
arkmish wants to merge 1 commit into
armishra/zk-snapshot-comparerfrom
armishra/zk-snapshot-summary
Draft

arkmish wants to merge 1 commit into
armishra/zk-snapshot-comparerfrom
armishra/zk-snapshot-summary

Conversation

@arkmish

@arkmish arkmish commented Sep 28, 2026 •

Copy link
Copy Markdown

Description

Add an offline subtree summary to help operators locate where a saved ZooKeeper snapshot's znodes and payload bytes are concentrated, without dumping node values or scanning a live ensemble.

This adapts Apache ZooKeeper's ZOOKEEPER-4566 implementation, reusing the native snapshot loader and existing CLI conventions.

bin/zkSnapshotRecursiveSummaryToolkit.sh snapshot.1 /app 1
  • Accepts a snapshot file, an existing absolute starting path, and a nonnegative display depth.
  • Reports total descendant count and subtree payload bytes for non-leaf nodes. Payload bytes include the starting node's own data; descendant count excludes the starting node.
  • Uses depth 0 for unlimited output. Depth limits only what is displayed: totals still cover the full subtree.
  • Includes leaf and ephemeral data in the totals, while omitting individual leaf entries from the output.
  • Supports uncompressed, gzip, and snappy snapshots, with explicit errors for invalid paths or corrupt input and both Unix/Windows launchers.

The tool loads the snapshot into memory and reads it without modification. Its output describes the saved snapshot, not a transaction-consistent reconstruction or current live state.

Tests

Validated SnapshotRecursiveSummaryTest, SnapshotComparerTest, and SnapStreamTest using Maven on JDK 11 with Java 8 API targeting:

Tests run: 33, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Coverage includes root and subtree selection, leaf behavior, exact byte/count totals, display-depth boundaries, null data, ephemerals, compression, invalid arguments, corruption, and shell launcher execution.

Actual Java 8 VM and Windows launcher execution were not available.

  • Local code review completed

Changes that Break Backward Compatibility (Optional)

None to existing server or client behavior. This adds a read-only command and does not alter snapshot formats or replay transaction logs.

Documentation (Optional)

Updated zookeeper-docs/src/main/resources/markdown/zookeeperTools.md with usage, sample output, depth/counting semantics, and operational limitations.

🤖 Generated with GitHub Copilot CLI

Adapt Apache ZooKeeper ZOOKEEPER-4566 by Szabolcs Bukros (05b2159). Reuse the comparer snapshot loader and fixtures, retaining subtree totals, depth behavior, launchers and CLI regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Functionality or fixes backported from a newer upstream version snapshot tooling Offline ZooKeeper snapshot inspection and comparison tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant