Skip to content

P05: Port paginated getChildren to ZooKeeper 3.8.7 - #181

Merged
bellatrix007 merged 1 commit into
adbansal/zk-387-p04-metricsfrom
adbansal/zk-387-p05-pagination
Dec 3, 2026
Merged

bellatrix007 merged 1 commit into
adbansal/zk-387-p04-metricsfrom
adbansal/zk-387-p05-pagination

Conversation

@bellatrix007

@bellatrix007 bellatrix007 commented Nov 18, 2026 •

Copy link
Copy Markdown

Description

Port P05 above #180: the paginated getChildren operation.

  • Source: final branch-3.6 (9d245933): Cherry-pick and adapt ZOOKEEPER-2260 for getChildren pagination #5 (2736f44a), Optimize paginated getChildren #8 (1d95c2ea) and the root-path fix Fix paginated getChildren returning no children for the root path #160 (d7d56cf3), reconciled with the 3.8.4 port (Optimize paginated getChildren #136).
  • Adds opcode getChildrenPaginated (71), Jute records GetChildrenPaginatedRequest, GetChildrenPaginatedResponse and PathWithStat, and ZooDefs.GetChildrenPaginated last-page markers (-1, -1).
  • Client API (additive): getChildren(path, watcher, maxReturned, minCzxId, czxidOffset, stat, nextPage), getAllChildrenPaginated(path, watch), getChildrenIterator(path, watcher, batchSize, minCzxId), PaginationNextPage and RemoteIterator.
  • Server: pages are ordered by (czxid, name) and bounded by maxReturned and the server jute.maxbuffer. Continuation is (nextPageCzxid, nextPageCzxidOffset). The parent READ ACL is checked before any children are read or a watch is added, as for getChildren2. The child watch is set only when the last page is returned. Root and chroot paths are supported.
  • 3.8.7 adaptations only: the target checkACL form used by getChildren2, the target default-watcher helper for the boolean watch overload, and JUnit 5 tests. Existing getChildren/getChildren2, records and opcodes are unchanged.

Inherited limitations (unchanged from the source):

  • The page-size estimate counts UTF-16 characters, not encoded bytes, so pages of non-ASCII names can exceed it.
  • Pages are not a snapshot. Deleting an already-returned child in the same czxid group shifts the offset and can skip a child for the page API and the iterator. getAllChildrenPaginated detects this case, but its overlap re-read has no empty-page guard.
  • The parent lock is held while a large child list is sorted. A client with a smaller jute.maxbuffer than the server can still reject a page.

Tests

  • New cases: GetChildrenPaginatedTest (17) and four DataTreeTest pagination cases. They cover page boundaries, czxid groups and offsets, large child sets, READ denial, root, chroot, concurrent mutation and watch re-registration after reconnect.
  • A focused red run with the root-path fix and READ check removed failed the three intended cases.
  • Interop: an older branch-3.6 fork client built from source passed 11/11 pagination checks against this server on JDK 8/11/17. Generated record encodings are byte-identical. A stock 3.6.3 server replies UNIMPLEMENTED to opcode 71 and closes the connection; the session continues after reconnect.
  • clean verify at fc94a294 passed 146 tests per JDK (8/11/17), 438 total, with no failures, errors or skips: 27 baseline + 21 new P05 cases + 98 existing chroot, watcher, request-processor, metrics, serialization and X509/ACL regression cases.
  • Java 11 assembly, RAT, Checkstyle and SpotBugs passed.
  • Tests used process-local -Djava.net.preferIPv4Stack=true. The first Java 17 run had five errors in the JMX test harness: RMI stubs advertised the host name's resolved address, which was not reachable locally after a network change. The Java 17 run was repeated with process-local -Djava.rmi.server.hostname=127.0.0.1 and passed. JDK 8/11 passed without it. IPv6 remains unqualified. Testing was local macOS ARM64 only, without full-suite, Linux or mixed-version ensemble qualification.
  • Local code review completed

Changes that Break Backward Compatibility (Optional)

Existing wire records and opcodes are unchanged. The new APIs require a server that supports opcode 71. A server without it replies UNIMPLEMENTED and closes the connection, so callers see an error and a reconnect. During a rolling upgrade, use pagination only once every server a client can connect to supports it. Opcode 71 is not used by upstream 3.8.7.

Client watcher behavior follows Apache 3.8.7: construction with a null default watcher is allowed, but getAllChildrenPaginated(path, true) requires a non-null default watcher and throws IllegalStateException before issuing the request if none is registered. The old fork rejected a null watcher during construction with IllegalArgumentException. Calls with watch=false do not require a default watcher.

Documentation (Optional)

Javadoc on the new ZooKeeper methods, PaginationNextPage and RemoteIterator. No user guide changes.

🤖 Generated with GitHub Copilot CLI

@bellatrix007
bellatrix007 force-pushed the adbansal/zk-387-p05-pagination branch from fc94a29 to b8901ce Compare November 27, 2026 06:10
Add the paginated getChildren operation (opcode 71) with its Jute
request/response records, the client page, list-all and iterator APIs,
server dispatch with READ authorization, and the DataTree implementation
ordered by (czxid, name) with buffer-bounded pages, including the
root-path lookup fix.

Adapt to 3.8.7: use the target checkACL form used by getChildren2, the
target default-watcher helper for the boolean watch overload, and
Jupiter tests. Add focused tests for page boundaries, large child sets,
READ denial, chroot, concurrent mutation and reconnect watch behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bellatrix007
bellatrix007 force-pushed the adbansal/zk-387-p05-pagination branch from b8901ce to 70a43de Compare November 27, 2026 10:12
@bellatrix007 bellatrix007 added the upgrade-3.8.x Port of LinkedIn patches onto Apache ZooKeeper 3.8.x label Dec 2, 2026

@arkmish arkmish left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Thanks for addressing the comments.

@bellatrix007
bellatrix007 merged commit 1188600 into li-dev/base-3.8.7 Dec 3, 2026
24 checks passed
@bellatrix007
bellatrix007 deleted the adbansal/zk-387-p05-pagination branch December 3, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upgrade-3.8.x Port of LinkedIn patches onto Apache ZooKeeper 3.8.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants