Skip to content

Backport the native snapshot size comparer - #153

Merged
arkmish merged 2 commits into
branch-3.6from
armishra/zk-snapshot-comparer
Oct 8, 2026
Merged

arkmish merged 2 commits into
branch-3.6from
armishra/zk-snapshot-comparer

Conversation

@arkmish

@arkmish arkmish commented Sep 28, 2026 •

Copy link
Copy Markdown

Description

Add an offline CLI for finding which subtrees grew, shrank, appeared, or disappeared between two ZooKeeper snapshots. It compares aggregate payload sizes and descendant counts, helping operators locate growth without querying a running ensemble.

This adapts Apache ZooKeeper's ZOOKEEPER-3427 implementation to the existing Java 8 and Commons CLI dependencies.

bin/zkSnapshotComparer.sh --left snapshot.1 --right snapshot.2.gz --bytes 0 --nodes 0
  • Reports right-minus-left deltas and paths present in only one snapshot.
  • Includes a path when either absolute difference is strictly greater than its configured threshold. Payload totals include the node itself; descendant counts exclude it.
  • Supports batch output and interactive exploration by depth or absolute path.
  • Reads uncompressed, gzip, and snappy snapshots, verifies their checksums, closes streams, and exits nonzero for invalid or corrupt input.
  • Includes Unix and Windows launchers using the existing zkEnv configuration.

The comparison includes ephemeral znodes, but does not compare payload contents, ACLs, or versions. Equal sizes and counts are not proof of identical contents. Snapshots are loaded into memory; no transaction logs are replayed.

Tests

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

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

The tests use synthetic native snapshots and real CLI subprocesses to cover additions/deletions, signed deltas, threshold boundaries, null data, ephemerals, compression, corruption, interactive input, and launcher argument forwarding.

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

  • Local code review completed

Changes that Break Backward Compatibility (Optional)

None to existing client or server interfaces. This is an additional offline tool; it does not modify snapshots, server request handling, or persistence formats.

Documentation (Optional)

Updated zookeeper-docs/src/main/resources/markdown/zookeeperTools.md with command options, examples, counting semantics, exit behavior, and snapshot-only limitations.

🤖 Generated with GitHub Copilot CLI

Adapt Apache ZooKeeper ZOOKEEPER-3427 by Michael Han (f90060b) to the existing Java 8 and CLI dependencies. Keep checksummed read-only snapshot loading, native launchers, operator documentation and synthetic CLI tests together.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@arkmish
arkmish marked this pull request as ready for review October 7, 2026 16:15
@arkmish
arkmish merged commit 9b0eeef into branch-3.6 Oct 8, 2026
20 checks passed
@arkmish
arkmish deleted the armishra/zk-snapshot-comparer branch October 8, 2026 04:23
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.

2 participants