You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "anmolnar (via GitHub)" <gi...@apache.org> on 2026/10/15 16:27:00 UTC
[PR] ZOOKEEPER-5097: Make DataTree snapshot serialization iterative [zookeeper]
anmolnar opened a new pull request, #2476:
URL: https://github.com/apache/zookeeper/pull/2476
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 <no...@anthropic.com>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5097: Make DataTree snapshot serialization iterative [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on PR #2476:
URL: https://github.com/apache/zookeeper/pull/2476#issuecomment-6304095792
Merged. Thanks @kezhuw @PDavid !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5097: Make DataTree snapshot serialization iterative [zookeeper]
Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #2476:
URL: https://github.com/apache/zookeeper/pull/2476#discussion_r4321381400
##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/DataTreeTest.java:
##########
@@ -418,6 +418,47 @@ public void run() {
assertTrue(ranTestCase.get(), "Didn't find the expected node");
}
+ /**
+ * Snapshot serialization must not depend on tree depth. This builds a very
+ * deep znode chain and serializes it on a thread with a small (512 KiB)
+ * stack, so the test is independent of the runner's default -Xss, then
+ * checks the result round-trips back to an equivalent tree.
+ */
+ @Test
+ @Timeout(value = 120)
+ public void testSerializeDeepTree() throws Exception {
+ final int depth = 4000;
+ final DataTree tree = new DataTree();
+ final StringBuilder path = new StringBuilder();
+ for (int i = 0; i < depth; i++) {
+ path.append("/a");
+ tree.createNode(path.toString(), new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, -1L, i + 1, i + 1, 1);
+ }
+
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
+ final Throwable[] failure = new Throwable[1];
+ final Thread serializer = new Thread(null, () -> {
+ try {
+ tree.serialize(oa, "tree");
+ } catch (Throwable t) {
+ failure[0] = t;
+ }
+ }, "deep-tree-serializer", 512 * 1024L);
+ serializer.start();
+ serializer.join();
+
+ assertNull(failure[0], "serialize() must not fail on a deep tree, but threw: " + failure[0]);
Review Comment:
```suggestion
assertNull(failure[0], "serialize() must not fail on a deep tree");
```
nit: assertion failure will report the exception anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5097: Make DataTree snapshot serialization iterative [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar merged PR #2476:
URL: https://github.com/apache/zookeeper/pull/2476
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org