Skip to content

Keeper getRecursiveChildren request - #100998

Merged
scanhex12 merged 24 commits into
ClickHouse:masterfrom
scanhex12:keeper_get_recursive_children
Apr 13, 2026
Merged

scanhex12 merged 24 commits into
ClickHouse:masterfrom
scanhex12:keeper_get_recursive_children

Conversation

@scanhex12

@scanhex12 scanhex12 commented Mar 28, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added getChildrenRecursive (ListRecursive) request to ClickHouse Keeper and lsr command to clickhouse-keeper-client. This closes #99916

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.886

@scanhex12
scanhex12 marked this pull request as draft March 28, 2026 12:10
@scanhex12
scanhex12 marked this pull request as ready for review March 28, 2026 13:38
@scanhex12 scanhex12 changed the title [WIP] Keeper getRecursiveChildren request Keeper getRecursiveChildren request Mar 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5aa2a83]

Summary: ⏳
Keeper Stress Tests (PR): Grafana: Run details (this run), Grafana: 1vs1 Comparison, Grafana: Historical progression

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, flaky check) failure
00352_external_sorting_and_constants FAIL cidb
Integration tests (amd_tsan, 2/6) failure
test_keeper_snapshot_chunked_transfer/test.py::test_recover_after_s3_read_error_during_transfer FAIL cidb
test_keeper_snapshot_chunked_transfer/test.py::test_recover_from_snapshot_sent_by_old_leader[remote_disk] FAIL cidb, issue
Unit tests (tsan) error
Unit tests (msan) error
Unit tests (amd_llvm_coverage) error
LLVM Coverage dropped

AI Review

Summary

This PR adds ListRecursive / lsr support for Keeper. The implementation is close, but two correctness issues remain in the client compatibility/error-handling path. I did not post new inline comments because both issues are already covered by existing unresolved inline comments from clickhouse-gh[bot] on the same code locations.

PR Metadata
  • ⚠️ Changelog entry is too vague: Keeper getRecursiveChildren request. does not clearly describe user-visible behavior.
  • Suggested replacement: Added Keeper recursive listing operation (ListRecursive) and clickhouse-keeper-clientcommandlsr [path] [limit] to list descendant znodes with a configurable limit.
Missing context
  • ⚠️ No CI logs/report links were provided in this task context, so runtime/compatibility validation could not be verified from CI artifacts.
Findings

⚠️ Majors

  • [src/Common/ZooKeeper/KeeperFeatureFlags.cpp:32-45] KeeperFeatureFlags::fromApiVersion does not enable GET_CHILDREN_RECURSIVE for KeeperApiVersion::WITH_GET_RECURSIVE. In mixed-version/fallback mode (when /keeper/feature_flags is unavailable), clients can incorrectly treat ListRecursive as unsupported.
    • Suggested fix: extend fromApiVersion mapping for WITH_REMOVE_RECURSIVE, WITH_CHECK_STAT, and WITH_GET_RECURSIVE to enable corresponding feature flags.
  • [src/Common/ZooKeeper/ZooKeeper.cpp:1230] tryListRecursive assigns res unconditionally even when code != ZOK, which is inconsistent with other try* APIs and can leak stale/partial output to callers that reuse the same vector.
    • Suggested fix: assign/move response.children to res only when code == ZOK.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ⚠️ fromApiVersion does not map WITH_GET_RECURSIVE to GET_CHILDREN_RECURSIVE.
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ Changelog entry is too vague for users.
Safe rollout ⚠️ Fallback compatibility path can disable feature unexpectedly in mixed-version scenarios.
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Fix API-version fallback mapping in KeeperFeatureFlags::fromApiVersion for WITH_GET_RECURSIVE (and related levels).
    2. Make ZooKeeper::tryListRecursive update output only on ZOK.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Mar 28, 2026
@scanhex12
scanhex12 marked this pull request as draft March 28, 2026 13:44
Comment thread src/Common/ZooKeeper/IKeeper.h Outdated
@@ -458,6 +458,31 @@ struct RemoveRecursiveResponse : virtual Response
{
};

struct GetChildrenRecursiveRequest : virtual Request
{
String path;

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.

Typo in the comment: this request limits the number of returned descendants, not "deleted nodes".

Could you reword to something like: strict limit for number of returned child nodes?

Comment thread src/Coordination/KeeperStorage.cpp Resolved
@scanhex12
scanhex12 force-pushed the keeper_get_recursive_children branch from e6b8548 to 33d9db5 Compare March 28, 2026 14:03
Comment thread src/Coordination/KeeperStorage.cpp Resolved
@scanhex12
scanhex12 marked this pull request as ready for review March 30, 2026 13:00
Comment thread src/Common/ZooKeeper/TestKeeper.cpp Resolved
Comment thread src/Common/ZooKeeper/ZooKeeper.cpp Resolved
Comment thread src/Coordination/KeeperStorage.cpp Resolved
Comment thread src/Coordination/KeeperDispatcher.cpp Resolved
Comment thread src/Common/ZooKeeper/TestKeeper.cpp Resolved
Coordination::Error code = response.error;

maybeSetSpanStatus(maybe_span, code);
res = std::move(response.children);

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.

tryGetChildrenRecursive moves response.children into res unconditionally, even when the request failed.

That differs from the existing tryGet/tryList pattern (they only write outputs on ZOK) and can leak stale/partial results to callers that reuse the same output vector.

Could you gate assignment the same way, e.g.:

maybeSetSpanStatus(maybe_span, code);
if (code == Coordination::Error::ZOK)
    res = std::move(response.children);
return code;

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.

This is correct

@scanhex12
scanhex12 requested a review from antonio2368 April 9, 2026 10:43
@antonio2368

Copy link
Copy Markdown
Member

What I meant was to have ListRecursive request and response internally.
getChildren is name of functions creating List requests.

Comment thread src/Coordination/KeeperStorage.cpp Resolved
@scanhex12
scanhex12 requested a review from antonio2368 April 9, 2026 18:02
@alexey-milovidov

Copy link
Copy Markdown
Member

The flaky check failure is fixed in #102148, let's update the branch.

@clickhouse-gh

clickhouse-gh Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 78.00% 84.10% +6.10%
Functions 90.40% 90.90% +0.50%
Branches 70.50% 76.60% +6.10%

Changed lines: 79.27% (562/709) · Uncovered code

Full report · Diff report

@antonio2368 antonio2368 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.

Update SystemTablesDataTypes::operationEnum

Coordination::Error code = response.error;

maybeSetSpanStatus(maybe_span, code);
res = std::move(response.children);

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.

This is correct

Comment thread src/Coordination/KeeperStorage.cpp Resolved
@scanhex12
scanhex12 enabled auto-merge April 13, 2026 12:50
@scanhex12
scanhex12 added this pull request to the merge queue Apr 13, 2026
Merged via the queue into ClickHouse:master with commit db75766 Apr 13, 2026
150 of 160 checks passed
@scanhex12
scanhex12 deleted the keeper_get_recursive_children branch April 13, 2026 14:31
@JTCunning JTCunning added the comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... label Apr 13, 2026
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 13, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @scanhex12 @antonio2368 — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce getChildrenRecursive request for clickhouse-keeper and keeper client

6 participants