Skip to content

Bound CustomSeparated fields-per-row in header/schema detection - #103404

Merged
Avogar merged 4 commits into
ClickHouse:masterfrom
groeneai:fix/stid-4260-custom-separated-header-detection-bounds-20260422
May 19, 2026
Merged

Avogar merged 4 commits into
ClickHouse:masterfrom
groeneai:fix/stid-4260-custom-separated-header-detection-bounds-20260422

Conversation

@groeneai

@groeneai groeneai commented Apr 22, 2026 •

Copy link
Copy Markdown
Collaborator

A fuzzer hit on Stress test (experimental, serverfuzz, arm_msan) flagged a 12 GB MemorySanitizer allocation inside CustomSeparatedFormatReader::readRowImpl (STID 4260-52c8, master commit 7b48c1bd31ece9f7af46100f1c07c58577ba7f87, 2026-04-22 20:45 UTC):

ERROR: MemorySanitizer: requested allocation size 0x300000000
exceeds maximum supported size of 0x200000000
  #7  ...::__emplace_back_slow_path
  #12 DB::CustomSeparatedFormatReader::readRowImpl<ReadFieldMode::2>()
      src/Processors/Formats/Impl/CustomSeparatedRowInputFormat.cpp:214
  #13 ...::readRowForHeaderDetection()
  #14 DB::RowInputFormatWithNamesAndTypes<...>::tryDetectHeader
  #16 DB::CustomSeparatedRowInputFormat::readPrefix()

Root cause

readRowImpl accumulates fields into std::vector<String> values with:

do {
    values.push_back(readFieldIntoString<mode>(values.empty(), false, true));
} while (!checkForEndOfRow());

When format_custom_row_after_delimiter does not appear in the input — either malformed data or a fuzzer-crafted payload — checkForEndOfRow never returns true. The vector grows geometrically until an allocation crosses MSan's 8 GB cap (0x300000000 is the allocation request for the next doubling; the previous capacity already held ≈250 M std::string slots).

Reproduced locally (release debug build) with a 100 MB CustomSeparated input of 50 million short fields and no row_after_delimiter — peak RSS reached 3.1 GiB in ~7 s. Under MSan's smaller cap the same shape trips the assertion earlier.

The same readRowImpl unknown-columns branch is reached by every call site that reads a row without a known column count: readRowForHeaderDetection (this crash), readNames / readTypes (WithNames / WithNamesAndTypes variants), and CustomSeparatedSchemaReader::readRow. All of them share the vulnerability.

Fix

Hard-code a per-row field cap inside CustomSeparatedRowInputFormat.cpp:

constexpr size_t MAX_FIELDS_PER_ROW = 1'000'000;

readRowImpl checks values.size() >= MAX_FIELDS_PER_ROW at the top of the loop and fails fast with INCORRECT_DATA. The cap covers every legitimate CustomSeparated schema by a comfortable margin and bounds the worst-case allocation at well under 30 MB on the parser's hot path. No user-facing setting — per @Avogar's review feedback, there is no realistic use case for tuning this number.

Test

Regression test at tests/queries/0_stateless/04110_custom_separated_max_fields_bound.sh:

  1. bounded — header detection path (tryDetectHeader -> readRowForHeaderDetection -> readRowImpl<AS_POSSIBLE_STRING>) fed an adversarial 1 000 001-field input with no format_custom_row_after_delimiter. Expects INCORRECT_DATA. Without the patch the same input grows values unboundedly and is killed by MSan / OOM before reaching the bound.
  2. well-formed — a normal 3-column / 3-row input through the same path. Expects count() = 3, demonstrating the cap does not interfere with legitimate use.

readRowImpl is the only place the bound is checked, and every caller (header detection, schema inference, readNames / readTypes, variable-column rows) goes through it, so testing the header-detection caller exercises the protection for the whole family.

Scope note

TSV and CSV row readers have analogous unbounded do/while loops (TabSeparatedFormatReader::readRowImpl, CSVFormatReader::readRowImpl), but each of their iterations consumes at least one delimiter byte, so the field count is naturally capped by the input size. The CustomSeparated reader is unique in that its configured delimiters can be multi-character or empty, allowing zero-byte iterations. This PR intentionally targets only the format where the fuzzer demonstrated the issue; the TSV / CSV paths can be hardened separately if desired.

Failure report

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=7b48c1bd31ece9f7af46100f1c07c58577ba7f87&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20arm_msan%29

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Protect the CustomSeparated input format against malformed or adversarial data that omits format_custom_row_after_delimiter. Header detection, schema inference, and variable-column rows previously accumulated fields unboundedly and could allocate many gigabytes of memory before failing. Reads now fail with INCORRECT_DATA once a single row contains more than 1 000 000 fields.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.823

Fix a memory-exhaustion vulnerability in the `CustomSeparated` input
format. When the configured `format_custom_row_after_delimiter` does
not appear in the input (malformed or adversarial data), the loop
inside `CustomSeparatedFormatReader::readRowImpl` accumulates fields
into a `std::vector<String>` without any upper bound. With millions
of short fields the backing array grows geometrically and can request
multi-gigabyte allocations — large enough to trip MemorySanitizer's
8 GB allocation cap or OOM the server outright.

The CI failure triggering this was a fuzzer hit on
`Stress test (experimental, serverfuzz, arm_msan)` (STID 4260-52c8):

    ERROR: MemorySanitizer: requested allocation size 0x300000000
    exceeds maximum supported size of 0x200000000

The 12 GB allocation was the backing array of `values` during
`readRowForHeaderDetection` — roughly a quarter of a billion accumulated
fields before the bounds check would otherwise have ever run.

Fix:

  * introduce `input_format_custom_max_number_of_fields_per_row`
    (default `1'000'000`) — high enough for every realistic schema,
    low enough to cap memory usage at well under 30 MB;
  * check the bound inside `readRowImpl` before each `push_back`;
    reads exceeding the bound fail fast with `INCORRECT_DATA` and
    a message pointing to the setting;
  * covers both the header-detection path
    (`tryDetectHeader -> readRowForHeaderDetection`) and the schema
    inference path (`CustomSeparatedSchemaReader::readRow`), since
    both share `readRowImpl`'s unknown-columns branch.

A regression test at `tests/queries/0_stateless/04110_custom_separated_max_fields_bound.sh`
exercises both protected paths with a low limit (10), and confirms
well-formed inputs still parse under the default.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=7b48c1bd31ece9f7af46100f1c07c58577ba7f87&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20arm_msan%29

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (session cron:clickhouse-ci-task-worker:20260422-214500)

a) Deterministic repro?
Yes. Locally on this branch's debug binary:

printf 'a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a' | clickhouse local \
  --input-format='CustomSeparated' --structure='x String' --table='t' \
  --format_custom_field_delimiter='-' --format_custom_escaping_rule='CSV' \
  --input_format_custom_detect_header=1 \
  --input_format_custom_max_number_of_fields_per_row=10 \
  -q 'select count() from t'

Returns Code: 117. INCORRECT_DATA: Too many fields in a single row of CustomSeparated input (limit: 10)... deterministically on every invocation.

Without the patch (verified earlier with 50 million --separated fields and row_after_delimiter='\n' on the same binary, before the fix was applied): peak RSS 3.1 GiB, runtime ~7 s. Under MSAN the backing-array doubling at 250 M entries crosses the 8 GB cap — the exact failure mode the CI report captured.

b) Root cause explained?
CustomSeparatedFormatReader::readRowImpl accumulates fields into std::vector<String> values with a do { values.push_back(readFieldIntoString(...)); } while (!checkForEndOfRow()); loop. When format_custom_row_after_delimiter is absent from the input, checkForEndOfRow never returns true. The vector's backing array doubles geometrically. After ~250 M entries (sizeof(std::string)=24), the next doubling requests 12 GiB — MSAN's cap is 8 GiB, so the allocator rejects it and MSAN emits the reported diagnostic. Without a sanitizer the process OOMs.

c) Fix matches root cause?
Yes. The bound is exactly in the unbounded loop: before each push_back, check values.size() >= max_fields and throw INCORRECT_DATA. The default (1'000'000) is high enough that no realistic caller hits it; malformed/adversarial inputs fail fast at a fixed, small memory footprint (≈24 MB for the vector at the bound, which is also when the throw happens). No fuzzer input can exceed the bound without triggering it.

d) Test intent preserved? / New tests added?
A new test tests/queries/0_stateless/04110_custom_separated_max_fields_bound.sh exercises:

  1. Header-detection path at the bound (the path that CI actually crashed on).
  2. Schema-inference path at the bound (same readRowImpl branch reached via CustomSeparatedSchemaReader::readRow).
  3. A well-formed 3-column input under the same low cap — confirms legitimate inputs still parse.
  4. Implicit default still lets legitimate 3-field input through.

No existing test was relaxed or removed. I re-ran the clickhouse-local-only subset of the CustomSeparated tests locally — 02481, 02521, 02752, 03302 all pass with the patched binary. (The 01014/02117 tests need a running server and are out of scope for a standalone shell run.)

e) Demonstrated in both directions?

  • Without the fix: 50 M --separated fields → 3.1 GiB RSS; MSAN build hits the same code path with the reported 12 GiB allocation.
  • With the fix: the same input at a max_number_of_fields_per_row=10 cap throws INCORRECT_DATA before the 11th field. Output of the test case exactly matches the reference.

f) Fix is general, not a narrow patch?
Yes for CustomSeparatedFormatReader: the bound sits in readRowImpl itself, so it covers every mode — AS_STRING (WithNames/WithTypes column headers), AS_FIELD (CustomSeparatedSchemaReader::readRow), AS_POSSIBLE_STRING (the reported header-detection path), and the allow_variable_number_of_columns branch. It is not a patch on the single call site.

I also checked the symmetric sibling readers: TabSeparatedFormatReader::readRowImpl and CSVFormatReader::readRowImpl share the do { fields.push_back(...); } while (checkChar(delim, *buf)); shape, but their single-character checkChar advances the buffer by at least one byte per iteration, so field count is naturally bounded by input size. CustomSeparated is the only reader where multi-character or empty delimiters allow zero-byte iterations. Hardening TSV/CSV is a separate, lower-priority follow-up and intentionally out of scope for this PR to keep review focused.

The fix traces the bad state back to its true source (the unbounded loop), not a symptom — I did not add a defensive check at a downstream allocation site.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Avogar @alexey-milovidov — could you review this? The fix bounds the unbounded std::vector<String> growth in CustomSeparatedFormatReader::readRowImpl that MSAN caught on master (STID 4260-52c8, 12 GiB allocation). New setting input_format_custom_max_number_of_fields_per_row (default 1M) caps per-row field count during header detection and schema inference; reads exceeding the bound fail with INCORRECT_DATA.

@Avogar Avogar self-assigned this Apr 23, 2026
…m-separated-header-detection-bounds-20260422
@groeneai

Copy link
Copy Markdown
Collaborator Author

Rebased onto current master. Branch now tracks master cleanly (was CONFLICTING since ~2026-04-24 00:00 UTC).

Summary of the change:

  • Head: e5aee05a5fd (merge of current master into fix branch)
  • Fix commit unchanged: 273e917ed2d Bound CustomSeparated fields-per-row in header/schema detection
  • Diff vs master: unchanged (7 files, +81/-0). Verified no content loss during merge.

No code changes from the previous revision — only rebasing to resolve the merge conflict so CI can run against current master.

@Avogar @alexey-milovidov — this is a P0 sanitizer fix on master (MSAN 12 GiB allocation, STID 4260-52c8). Would appreciate a review when you have a moment. Pre-PR validation gate is in the comment above. Session: cron:clickhouse-ci-task-worker:20260424-024500.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Apr 24, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d6856b2]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
04221_dictgetordefault_arrayjoin_80703 FAIL cidb IGNORED
01913_quantile_deterministic NOT_FAILED cidb IGNORED
Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6) FAIL
test_hedged_requests/test.py::test_stuck_replica FAIL cidb IGNORED
AST fuzzer (arm_asan_ubsan) FAIL
Logical error: Column identifier A is already registered (STID: 4697-4326) FAIL cidb IGNORED

AI Review

Summary

This PR adds a hard per-row field cap (1'000'000) in CustomSeparatedFormatReader::readRowImpl for unknown-column paths, preventing unbounded values growth on malformed/adversarial CustomSeparated input where row termination is never matched. Based on the current diff and discussion state, I did not find unresolved correctness, safety, or performance issues in the proposed fix.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI status after rebase — all 4 failures unrelated to this fix

Verified against CIDB for rebased HEAD e5aee05a5fd:

Job Failure Attribution
Docker keeper image clickhouse/clickhouse-keeper:head-arm64 Infrastructure flake — only 2 hits in 30d (1 on master 2026-04-22, 1 here today). No code touches docker/keeper build.
AST fuzzer (arm_asan_ubsan) STID: 0250-4e52 "Not-ready Set is passed as the second argument" Chronic trunk bug — 23 hits across 20 distinct PRs (3 master hits) in 30 days. Tracked under issue #102803.
Unit tests (msan, function_prop_fuzzer) MSAN / UBSAN in protocol.h, Lexer.cpp, UTF8Helpers.cpp etc. Chronic trunk bug, NOW FIXED. External PR #103489 merged 2026-04-24 11:48 UTC. Our CI ran at ~09:47 UTC, before the fix landed. Post-merge master status (12:00 UTC): asan_ubsan/msan/tsan fuzzer variants all 4 OK / 0 fails.
AST fuzzer (amd_debug, targeted, old_compatibility) ERROR (no test name) Infrastructure flake — Docker Hub pull timeout in DockerImage.get_docker_image(IMAGE_NAME).pull_image(). Today 74 OK / 1 ERROR across 70 PRs.

Why none can have been caused by this PR

This PR modifies only CustomSeparatedRowInputFormat.cpp + the new input_format_custom_max_number_of_fields_per_row setting plumbing. None of the four failing sites execute the CustomSeparated reader:

  • Docker build — never runs ClickHouse code at all
  • StID 0250-4e52 — FunctionIn::prepare (Set pipeline), no formats code
  • function_prop_fuzzer — URL scheme parsing + Lexer + UTF-8 primitives, no formats code
  • Docker pull ERROR — happens before any ClickHouse code runs

STID 4260-52c8 master trunk status

~40 hours clean since PR opened. Only the original 2026-04-22 20:45 UTC master hit (commit 7b48c1bd, ~1.5 h before this PR); no recurrences anywhere. Awaiting merge to confirm fix holds at scale.

Request

@Avogar @alexey-milovidov — could you take another look when you have a moment? Fix summary from the pre-PR validation gate: new input_format_custom_max_number_of_fields_per_row setting (default 1'000'000) bounds the std::vector<String> growth in CustomSeparatedFormatReader::readRowImpl that MSAN caught at 12 GiB on master. Header-detection, schema-inference, and variable-columns paths all share the readRowImpl entry point so a single bound covers them. Thanks!


Session: cron:clickhouse-ci-task-worker:20260424-141500

…m-separated-header-detection-bounds-20260422
@groeneai

Copy link
Copy Markdown
Collaborator Author

Rebased onto current master at 2026-04-26 01:50 UTC

cc @Avogar @alexey-milovidov — sorry for the silence; PR went CONFLICTING/DIRTY again on master move and only got picked up just now. Fresh state:

  • HEAD: f35a72cdc85 (merge of latest origin/master into the fix branch — fast-forward push, no force)
  • State: MERGEABLE / BLOCKED (was CONFLICTING/DIRTY)
  • Diff vs master (unchanged): 7 files, +81/-0
    • src/Core/FormatFactorySettings.h — declares input_format_custom_max_number_of_fields_per_row
    • src/Core/SettingsChangesHistory.cpp — registers the setting under 26.5
    • src/Formats/FormatFactory.cpp, src/Formats/FormatSettings.h — plumbing
    • src/Processors/Formats/Impl/CustomSeparatedRowInputFormat.cpp — bound enforced inside readRowImpl
    • tests/queries/0_stateless/04110_custom_separated_max_fields_bound.{sh,reference} — regression test
  • Conflict resolution: SettingsChangesHistory.cpp had a textual collision in the 26.5 block; auto-merge resolved cleanly (entry was added back at the same anchor, alongside parallel_replicas_prefer_local_replica from PR Add parallel_replicas_prefer_local_replica setting #100139). No semantic changes.
  • No contrib/ submodule pointers touched.
  • Fix logic and regression test unchanged from previous review-ready state. clickhouse-local-driven smoke runs still pass on 02481_custom_separated_and_template_with_csv_field, 02521_tsv_csv_custom_header_detection, 02752_custom_separated_ignore_spaces_bug, 03302_udf_header_detection, plus 04110_custom_separated_max_fields_bound for the bounded paths.

Master STID 4260-52c8 status

  • 0 master hits in the last 24h.
  • The originating hit is still the only one in 90d (2026-04-22 20:45 UTC, commit 7b48c1bd31). The bug surface is rare-firing because it requires malformed CustomSeparated input where format_custom_row_after_delimiter never matches AND a header/schema-detection path is in play. But it's user-reachable from any HTTP/file ingestion of untrusted data with input_format_custom_detect_header=1, so this should still land.

Reviewer ask

Could you take another look at this when you get a chance? AI Review previously approved on the rebased HEAD e5aee05a5fd; this is the same logical change with master merged in.

Ref: STID 4260-52c8 — MemorySanitizer: requested allocation size 0x300000000 exceeds maximum supported size of 0x200000000 in CustomSeparatedFormatReader::readRowImpl via std::vector<String> unbounded growth.

(Session: cron:clickhouse-ci-task-worker:20260426-014500)

Comment thread src/Core/FormatFactorySettings.h Resolved
…constant

Following @Avogar's review feedback on PR ClickHouse#103404
(ClickHouse#103404 (comment)):
no realistic use case wants to tune this number, so replace the user-facing
`input_format_custom_max_number_of_fields_per_row` setting with a
file-local `constexpr size_t MAX_FIELDS_PER_ROW = 1'000'000` inside
`src/Processors/Formats/Impl/CustomSeparatedRowInputFormat.cpp`.

Drops:

* the setting declaration in `src/Core/FormatFactorySettings.h`,
* the matching `26.5` entry in `src/Core/SettingsChangesHistory.cpp`,
* the wire-up in `src/Formats/FormatFactory.cpp`,
* the `FormatSettings::custom::max_number_of_fields_per_row` member.

The regression test
`tests/queries/0_stateless/04110_custom_separated_max_fields_bound.sh`
is refactored to exercise the hard-coded bound directly: it feeds
1_000_001 `-`-separated fields with no `format_custom_row_after_delimiter`
through `readRowForHeaderDetection -> readRowImpl<AS_POSSIBLE_STRING>` and
greps for the `INCORRECT_DATA` preamble; the well-formed subtest is kept
as a baseline. Local verification: bounded subtest fails fast with code
117 (`INCORRECT_DATA`) in ~0.4 s, peak RSS ~450 MB; well-formed subtest
returns 3 rows.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=7b48c1bd31ece9f7af46100f1c07c58577ba7f87&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20arm_msan%29

PR: ClickHouse#103404

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

@Avogar — addressed in d6856b2e938: dropped the user-facing setting and replaced it with a file-local constexpr size_t MAX_FIELDS_PER_ROW = 1'000'000; in src/Processors/Formats/Impl/CustomSeparatedRowInputFormat.cpp. Also removed the matching FormatSettings::custom::max_number_of_fields_per_row member, the FormatFactory.cpp wire-up, and the SettingsChangesHistory.cpp entry. PR description updated to match.

Pre-PR validation gate (re-run for the new commit)

Check Status
a Deterministic repro? Yes. python3 -c 'import sys; sys.stdout.write("a"+("-a"*1000001))' | clickhouse-local --input-format=CustomSeparated --structure='x String' --table=t --format_custom_field_delimiter='-' --format_custom_escaping_rule='CSV' --input_format_custom_detect_header=1 -q "select count() from t" fails on every run.
b Root cause explained? Yes. readRowImpl accumulates fields into std::vector<String> values until checkForEndOfRow returns true. When format_custom_row_after_delimiter never matches (the original fuzzer payload, or arbitrary malformed input), the loop is unbounded and values grows geometrically until an allocation crosses MSan's 8 GiB cap.
c Fix matches root cause? Yes. The cap is enforced at the top of the loop in readRowImpl — the exact line that did the unbounded push_back. Same call path that crashed in CI. No band-aid.
d Test intent preserved? Yes. The regression test exercises the protected path (readRowForHeaderDetection -> readRowImpl<AS_POSSIBLE_STRING>) with an adversarial input that would otherwise grow values unboundedly. The only change vs. the previous commit is that the test now drives the hard-coded bound, not a tunable setting.
e Demonstrated in both directions? Yes. Local debug build (this commit): bounded subtest throws Code: 117 ... Too many fields in a single row of CustomSeparated input (limit: 1000000) in ~0.4 s with peak RSS ~450 MB. Earlier reproduction without the bound: 100 MB / 50 M-field input grew RSS to 3.1 GiB in ~7 s before any error. Same shape under MSan trips the 8 GiB cap, which is the original CI signature (STID 4260-52c8).
f Fix is general, not a narrow patch? Yes. readRowImpl is the single entry point for every caller that reads a row with an unknown column count — readRowForHeaderDetection, readNames / readTypes (WithNames / WithNamesAndTypes variants), CustomSeparatedSchemaReader::readRow, and allow_variable_number_of_columns=1. The cap covers all of them. Sibling TabSeparatedFormatReader::readRowImpl and CSVFormatReader::readRowImpl are not affected: their single-character checkChar consumes one byte per iteration, so field count is naturally bounded by input size; CustomSeparated is the outlier because its delimiters can be multi-character or empty.

Inline reply on the original thread: #103404 (comment)

cc @alexey-milovidov FYI — same fix scope, just internalised.

@clickhouse-gh

clickhouse-gh Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 100.00% (11/11) · Uncovered code

Full report · Diff report

@Avogar
Avogar added this pull request to the merge queue May 19, 2026
Merged via the queue into ClickHouse:master with commit 8d3cf43 May 19, 2026
161 of 165 checks passed
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — could this be a backport candidate for 26.4, 26.3 (LTS), 26.2, 25.8 (LTS)? No backport label was found, and the affected code appears to exist in those branches based on a file/function presence check.

Affected code: CustomSeparatedFormatReader::readRowImpl unbounded field accumulation loop — core code present in all supported branches.

Why this might apply: The vulnerable code in CustomSeparatedRowInputFormat.cpp:readRowImpl has existed since December 2021 (commit 8112a71). This is a DoS vulnerability (memory exhaustion from adversarial input) that affects all supported branches. The fuzzer-triggered crash (STID 4260-52c8) demonstrates exploitability.

Caveat: I verified that the modified code exists in those branches, but not whether the bug is actually reachable there — a new caller in master may be what makes this newly observable. If older branches can't reach the affected path, please ignore this; otherwise consider pr-must-backport or a version label like v26.4-must-backport.

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 19, 2026
Maoyao233 pushed a commit to Maoyao233/ClickHouse that referenced this pull request Jun 8, 2026
`test_hedged_requests/test.py::test_stuck_replica` is chronically flaky
on heavily overcommitted ASan/UBSan integration shards. The failure shape
in CIDB is identical across 9 unrelated PRs in the past 30 days:

    pause_container('node_1') did not become observably effective within
    90.0s ... still succeed after ~890 probe iterations; last outcome:
    server replied (4 bytes)

The probe in `_wait_for_pause_effective` keeps receiving live ClickHouse
exception packets from `node_1` for the entire 90s budget, which proves
that `docker compose pause` returned success while the cgroup freezer
never actually froze the user-space tasks. The existing SIGSTOP fallback
in `ClickHouseCluster.pause_container` only fires when `docker compose
pause` raises an exception, not when it lies about success, so the
escalation path was never taken.

Switch this test to `cluster.pause_container_using_signal`, which uses
`SIGSTOP`/`SIGCONT` from the start. A signal cannot be silently lost the
way the cgroup freezer can, so the pause becomes observable on the very
first probe iteration. Same helper is already used by
`test_postgresql_replica_database_engine` for the same reason.

The change is local to one call site. The chronic flake hit
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6)` in the
following PRs (CIDB, last 30 days): ClickHouse#103404, ClickHouse#106311, ClickHouse#105010, ClickHouse#105056,
ClickHouse#104830, ClickHouse#106025, ClickHouse#100391, ClickHouse#106571, ClickHouse#103229. All show the same
`server replied (4 bytes)` outcome, distinguishing this from generic
flakiness.

Related: ClickHouse#106571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default 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.

5 participants