Skip to content

ZOOKEEPER-5097: Make DataTree snapshot serialization iterative - #2476

Merged
anmolnar merged 2 commits into
apache:masterfrom
anmolnar:ZOOKEEPER-5097
Oct 20, 2026
Merged

anmolnar merged 2 commits into
apache:masterfrom
anmolnar:ZOOKEEPER-5097

Conversation

@anmolnar

Copy link
Copy Markdown
Contributor

DataTree.serializeNode walked the tree recursively, one frame per znode
level, which does not scale to very deep trees. Rewrite it as an iterative
pre-order traversal over an explicit heap stack, removing the dependency on
tree depth. Traversal order, per-node locking and emitted records are
unchanged, so the on-disk snapshot format is identical. Adds a regression
test that serializes a very deep chain on a small-stack thread and checks it
round-trips.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

@PDavid PDavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks. 👍

Special thanks for adding the test for it.

@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!

Comment thread zookeeper-server/src/test/java/org/apache/zookeeper/server/DataTreeTest.java Outdated
…aTreeTest.java


Assertion failure will report the exception anyway

Co-authored-by: Kezhu Wang <kezhuw@gmail.com>
@anmolnar
anmolnar merged commit 9b014bf into apache:master Oct 20, 2026
17 of 18 checks passed
@anmolnar

Copy link
Copy Markdown
Contributor Author

Merged. Thanks @kezhuw @PDavid !

@anmolnar
anmolnar deleted the ZOOKEEPER-5097 branch October 20, 2026 23:27
anmolnar added a commit that referenced this pull request Oct 21, 2026
Reviewers: PDavid, kezhuw
Author: anmolnar
Closes #2476 from anmolnar/ZOOKEEPER-5097
anmolnar added a commit that referenced this pull request Oct 21, 2026
Reviewers: PDavid, kezhuw
Author: anmolnar
Closes #2476 from anmolnar/ZOOKEEPER-5097
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.

3 participants