Skip to content

Allow to enable nuraft streaming mode - #101427

Merged
kssenii merged 5 commits into
masterfrom
nuraft-streaming
Apr 10, 2026
Merged

kssenii merged 5 commits into
masterfrom
nuraft-streaming

Conversation

@kssenii

@kssenii kssenii commented Mar 31, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Added keeper settings nuraft_streaming_mode (by default false), nuraft_max_log_gap_in_stream, nuraft_max_bytes_in_flight_in_stream. Closes #90743.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.792

@clickhouse-gh

clickhouse-gh Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7b67d03]

Summary: ❌

job_name test_name status info comment
Stress test (arm_asan_ubsan, s3) failure
Server died FAIL cidb, issue ISSUE EXISTS
Logical error: Cannot modify size limits to A in size and B in elements: not enough space freed. Current size: C/D, elements: E/F (G) (STID: 4012-44fe) FAIL cidb, issue ISSUE EXISTS
Stress test (arm_msan) failure
Server died FAIL cidb, issue ISSUE EXISTS
MemorySanitizer: use-of-uninitialized-value (STID: 4179-5154) FAIL cidb IGNORED

AI Review

Summary

This PR adds Keeper-side support for NuRaft streaming mode via new coordination settings, wires them into KeeperServer, and adds integration coverage for config/log visibility. High-level verdict: the change is directionally good, but there is one correctness blocker in the new setting plumbing that can produce an invalid negative throttle value at runtime.

Findings

❌ Blockers

  • [src/Coordination/KeeperServer.cpp:550] nuraft_max_bytes_in_flight_in_stream is cast from UInt64 to int64_t without bounds checks. Values > INT64_MAX overflow and can become negative, violating throttling semantics and causing hard-to-debug behavior.
    Suggested fix: validate/clamp before assignment (analogous to getValueOrMaxInt32AndLogWarning) and log when clamping occurs.
Tests
  • ⚠️ Add an integration/boundary test for oversized nuraft_max_bytes_in_flight_in_stream (INT64_MAX + 1) to ensure overflow handling remains correct and regressions are caught.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ✅
No magic constants ✅
Backward compatibility ⚠️ Oversized setting values are not safely handled and can produce invalid runtime behavior.
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ⚠️ Invalid high values for a new setting can break behavior in production-like rollouts.
Compilation time ✅
No large/binary files ✅
Performance & Safety
  • Unsafe signed conversion in KeeperServer can corrupt the configured in-flight byte limit and destabilize request flow-control under streaming mode.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Add bounds-safe handling for nuraft_max_bytes_in_flight_in_stream before storing into int64_t.
    • Add a boundary test for oversized values.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Mar 31, 2026
@kssenii
kssenii requested a review from antonio2368 March 31, 2026 18:57
params.max_log_gap_in_stream_
= getValueOrMaxInt32AndLogWarning(coordination_settings[CoordinationSetting::nuraft_max_log_gap_in_stream], "nuraft_max_log_gap_in_stream", log);
params.max_bytes_in_flight_in_stream_
= static_cast<int64_t>(coordination_settings[CoordinationSetting::nuraft_max_bytes_in_flight_in_stream]);

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.

Casting nuraft_max_bytes_in_flight_in_stream from UInt64 to int64_t without bounds checking can overflow for values greater than INT64_MAX, producing a negative limit. That can break NuRaft throttling semantics in hard-to-debug ways.

Please clamp/validate this setting before assignment (similar to getValueOrMaxInt32AndLogWarning) and log a warning when truncation happens.

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.

@kssenii let's do something similar to getValueOrMaxInt32AndLogWarning

@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member

The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158

assert "nuraft_max_bytes_in_flight_in_stream=4194304" in conf


def test_streaming_mode_logged_at_startup(started_cluster):

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.

Please add a boundary test for oversized nuraft_max_bytes_in_flight_in_stream (e.g. value > INT64_MAX). The implementation currently stores this setting in a signed int64_t field, so this edge case can silently produce an invalid negative throttle.

Without this coverage, regressions in overflow handling are easy to miss even after the cast/validation fix in KeeperServer.

@alexey-milovidov

Copy link
Copy Markdown
Member

The test_database_iceberg_nessie_catalog and test_database_iceberg_lakekeeper_catalog failures in this PR's CI are false positives caused by a bug in PR #100583 (merged to master on 2026-04-09 at 11:19 UTC). That PR broke the metadata file path resolution in getMetadataLocation for Iceberg catalog tests — it produced a doubled S3 key like table_path/warehouse-rest/table_path/metadata/... instead of table_path/metadata/..., causing MinIO to return 403.

The bug was reverted by PR #102247 (merged at ~14:48 UTC). All nessie/lakekeeper test failures between these two merges are unrelated to this PR.

@clickhouse-gh

clickhouse-gh Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 90.90% 90.90% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 80.65% (25/31) | lost baseline coverage: 4 line(s) · Uncovered code

Full report · Diff report

@antonio2368

Copy link
Copy Markdown
Member

Stress test (arm_msan) - should be fixed by #102158

Stress test (arm_asan_ubsan, s3) - #95983, I didn't find new fix

@kssenii
kssenii added this pull request to the merge queue Apr 10, 2026
Merged via the queue into master with commit cd78845 Apr 10, 2026
160 of 163 checks passed
@kssenii
kssenii deleted the nuraft-streaming branch April 10, 2026 10:26
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 10, 2026
antonio2368 added a commit that referenced this pull request Apr 10, 2026
…ecovery path

Fix `LOGICAL_ERROR` abort during SLRU filesystem cache dynamic resize
(issue #95983, STID `4012-44fe`).

**Per-queue stat fix (core bug):**
`SLRUFileCachePriority::collectCandidatesForEviction` shared a single
`FileCacheReserveStat` across both sub-queue passes. The probationary
pass accumulated `releasable_size`, then the protected pass's stopping
condition was immediately satisfied by probationary leftovers — so zero
protected candidates were collected. `modifySizeLimits` then threw
because the protected queue still exceeded its new limit. Fix: use
per-queue local stat objects and merge them afterward.

**SLRU recovery path fix:**
When eviction fails and entries are restored, they now go back to their
original queue (protected or probationary) instead of all defaulting to
probationary. `EvictionCandidates` captures the queue type before
invalidation, and a new `addForRestore` virtual method routes entries
back to the correct sub-queue. Recovery uses `result_limits = prev_limits`
since entries existed under those limits.

**`SplitFileCachePriority::modifySizeLimits` no-op guard fix:**
The no-op guard compared `system_segment_size_ratio` (Data/System split)
against `size_ratio_` (SLRU protected/probationary ratio) — different
concepts. This caused real resizes to be silently skipped. Fix: compare
only `max_size` and `max_elements`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101427&sha=7b67d034be1a37512c7fbc8c9b428f2eeb0907ba&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Related PR: #101427

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@JTCunning JTCunning added the comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... label Apr 21, 2026
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-improvement Pull request with some product improvements 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.

RFC: Enable NuRaft Streaming Mode in ClickHouse Keeper

5 participants