Repository navigation
Tag functional tests averaging over 60s under MSan with no-msan - #115050
Conversation
MSan stateless jobs are the slowest functional-test jobs in CI and sit at the
edge of the 9000s job timeout - the private
`Stateless tests (amd_msan, distributed cache, meta in keeper, s3 storage, sequential, 2/2)`
job used 8324s of its 9000s budget and was killed during teardown even though
every test passed.
MSan is ~5.8x slower than release on the same tests, and the cost is
concentrated in a long tail of heavy tests: under MSan, 8 tests take over 180s
each and the 30 slowest account for ~48% of a sequential shard's runtime.
Tag every functional test whose mean duration under MSan exceeds 60s with
`no-msan`. The set was taken from `play.clickhouse.com`: tests in the public
`Stateless tests (amd_msan, WasmEdge, {parallel,sequential}, N/M)` checks over
the last 30 days, `test_status = 'OK'`, at least 20 runs, and
`avg(test_duration_ms) > 60000`. 351 tests matched; 30 of them no longer exist
in `master` (reverted, split, or removed), leaving 321. One
(`04062_text_index_json_all_values_ghdata`) already carried the tag, so 320
files change here.
This removes 19.2% of the parallel MSan stateless test time (~24800s per
commit) and 36.6% of the sequential MSan stateless test time (~4100s per
commit).
Note the trade-off: a large share of these are the ZooKeeper, replication,
mutation and race tests where MSan is most likely to find real uninitialized
memory. They keep running under ASan, UBSan and TSan.
|
Workflow [PR], commit [9848986] Summary: ✅ AI ReviewSummaryAdds Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings. |
`getTestTagsLength` (`src/Client/TestTags.cpp`) strips the tag block so it is not echoed, but once the first line is `-- Tags:` it keeps consuming *every* following `--` comment line, stopping only at the first non-comment line. So prepending `-- Tags: no-msan` to a `.sql` test that starts with its own comments removes those comments from the text the client sees. That broke four tests in Fast test: #115050 (comment) In `00182_functions_higher_order_and_consts` the swallowed line was `--{echoOn}` itself, so echo was disabled and every query line disappeared from the output. In `03712_tuple_inside_nullable_implicit_cast_for_in_function_*` the swallowed line was a descriptive comment that the reference expects to see echoed. Fast test runs only a subset, so instead of patching the four reported tests, check the invariant over every `.sql`/`.sql.j2` file this branch touches: the text after `getTestTagsLength`, with leading whitespace trimmed (the client trims it in `analyzeMultiQueryText`), must be byte-identical to before. Nine files violated it - the four above plus `04054_ast_json_serialization`, `04513_type_pair_matrix_comparison`,`04514_type_pair_matrix_arithmetic`, `04518_type_pair_matrix_comparison_integer_left` and `04519_type_pair_matrix_arithmetic_signed_wide`, which would have failed later in the full stateless run. Separate the tag from the test's own comments with a blank line, which stops `getTestTagsLength` at the tag line. The invariant now holds for all 77 `.sql`/`.sql.j2` files on the branch. Verified by running the affected tests through `clickhouse local --multiquery` (rendering the `.j2` templates first): the output on `master`, which the broken revision changed, is restored exactly. `getTestTagsLength` itself is left alone: 1293 tests in `master` already have a `-- Tags:` line followed by a comment, 27 of them use `echoOn`, and their references were generated with the current behaviour.
Build profile diff (arm_release)No arm_release build profile data for commit d0a2ba2 - the build was skipped, reused from cache, or predates profile upload. |
…-functional-tests
…w-functional-tests`
|
🕵 @groeneai, the prior flaky-check failures were in debug/ASan/TSan jobs and are unrelated to this PR’s MSan-only tag changes: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115050&sha=8713c46d2c9d892272637e3d63b7362eecce5a40&name_0=PR. I merged current |
|
Confirmed, and I checked the mechanism rather than taking it on trust: The refreshed run on
The reason the failing set looks different each run is The inflation is the flaky check's own concurrency, not the tests. It runs one changed test on Two things follow for this PR. Those 4 tests all now carry I would not fix these in your PR. Nothing here is a correctness failure, and none of the 4 has ever hit Report for the prior head: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115050&sha=8713c46d2c9d892272637e3d63b7362eecce5a40&name_0=PR |
… under MSan The file already carries `no-asan`, so adding `no-msan` would have removed the last memory-safety sanitizer from the filesystem-cache read path. Its mean duration under the public `amd_msan, WasmEdge` jobs is 75.9 s over 9339 runs, which is at the low end of the tagged set, so the runtime saved does not justify losing that coverage. This makes it the third test kept under MSan for sanitizer-coverage reasons.
…-functional-tests
…-functional-tests Conflicts were all modify/delete on test files this PR only retagged: master removed `04651_fuzzer_degenerate_logical_predicate.sql` (flaky) and the old-analyzer tests, and migrated the disk-modifying and variant-filename tests to integration tests. The deletions win; the `no-msan` tags on those files are moot. Co-Authored-By: Claude Fable 5 <[email protected]>
…-functional-tests
…-functional-tests # Conflicts: # tests/queries/0_stateless/03927_sharded_aggregation.sql # tests/queries/0_stateless/04039_merge_tree_snapshot_teardown_race.sh
…-functional-tests
…-functional-tests # Conflicts: # tests/queries/0_stateless/04327_backup_s3_base_credentials_metadata.sh
…-functional-tests Five conflicts, all on the `Tags:` line of a tagged test: * `00974_query_profiler.sql` - master added `no-msan` itself (with a rationale comment about `QUERY_PROFILER_SUPPORTED`) plus `no-flaky-check`; took master's block verbatim, so the file drops out of this PR's diff. * `01161_all_system_tables.sh`, `03593_funcs_on_empty_string.sql` - master added `no-flaky-check`; combined it with our `no-msan`. * `04613_arrow_empty_nested_offsets.sh` - master added `long`; combined it with our `no-msan`. * `04757_schema_inference_cache_key_settings.sh` - master split this test into five per-carrier files and dropped its `Tags:` line entirely because the remaining shard reads no Parquet. The >60 s MSan average that selected the file was measured on the pre-split test and no longer describes this shard, so master's deletion is accepted and the tag is not re-added. Tag count is now 305 files (307 before this merge). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Merged |
It runs longer than 180 seconds in the private flaky check (`amd_asan_ubsan`, parallel replicas): https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=69383&sha=9c5561038f0eb0b35aa989200b50e647053b40d4&name_0=PR&name_1=Stateless%20tests%20(amd_asan_ubsan%2C%20flaky%20check%2C%20s3%20storage%2C%20meta%20in%20keeper) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
Under MSan the test runs at 80-90% of the 600 s per-test timeout (master amd_msan: median 470 s, max 532 s over 6 passing runs, one Timeout! at 600.25 s), against 16 s in amd_debug. The failing job's query_log: six single-threaded INSERTs parsing 640 000 JSON documents 246 s, 18 comparison queries over both tables ~300 s, OPTIMIZE FINAL 22 s; the SHARED table and its plain twin cost the same, and the time does not depend on the random settings draw. The body and reference are unchanged, so ASan, UBSan, TSan and the other builds keep running it. Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/40338606213/job/121633043306 Related: ClickHouse#127000 Related: ClickHouse#115050 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115050&sha=caf5e571aafebedc1da13309e917005b30243674&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. |
|
The fix is in progress: #127925 (test-only,
#127925 branched before |
The flaky check under ASan failed with `Test runs too long (> 180s)`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115050&sha=7314a4492cf8d17db2113eea4691b6cd580aaa26&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 PR: #115050 Insert 4 parts of 100000 rows instead of 500000, and generate `a` deterministically so that every part contains all 20000 `(a, b)` pairs. The expected result stays 20000 without relying on `rand`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Thanks @groeneai, noted that #127925 fixes the The only failure on 7314a44 was |
The test (added by ClickHouse#127100) needs more data manifests than the 64 that ManifestFilesPrefetcher reads ahead, so it writes 70 of them with 70 INSERTs and then reads them twice on one thread with a cold metadata cache. Under MSan in the parallel stateless job that costs 1.7-2.6 s per manifest. In master `Stateless tests (amd_msan, parallel, 3/3)` it ran 16 times since the merge: mean 280 s, p99 533 s, max 543 s of the 600 s per-test timeout, so a timeout kill is an ordinary tail event. Per-query time of the 543 s run (master c0e5c9a): 70 INSERTs 111 s, first ALTER DELETE (cold cache) 176 s, icebergLocal with max_threads = 1 193 s, with max_threads = 8 25 s. The mean is 4.7x the 60 s MSan cutoff of ClickHouse#115050. Same remedy as 0d02623 (01721_join_implicit_cast_long) and ClickHouse#125128 (05271_promql_label_matcher_pushdown). The test still runs under ASan, UBSan, TSan, debug and release. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=c0e5c9ad4ad2ac0426f2d75bf4ef6764dfc01814&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_msan%2C%20parallel%2C%203%2F3%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`grep -o -m1` stops after the first matching line, but prints every match on that line. When the error message contains `MEMORY_LIMIT_EXCEEDED` twice on one line, the test printed it twice and failed in `Fast test`, e.g. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115050&sha=022cfff09c991631c8a4b90abf39ced8c2caec5b&name_0=PR&name_1=Fast%20test (ClickHouse#115050). Keep only the first match with `head -n1`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both tests averaged only just over 60 s under MSan (63.2 s and 60.6 s) before this PR cut their workloads by 5-10x, so the old measurements no longer justify excluding them. Keep running them under MSan, as with the other tests made faster. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test (added by ClickHouse#129328) sweeps key shapes, join algorithms, join kinds, key widths and block sizes: about 190 joins of a 3,300-row table with a 3,200-row one. On master its six `Stateless tests (amd_msan, parallel, 3/3)` runs so far average 288.6 s (max 401.7 s, against the 600 s per-test timeout), while release takes 6.9 s, debug 5.0 s, asan_ubsan 41.8 s and tsan 87.6 s (p50). That is far over ClickHouse#115050's bar (mean OK duration above 60 s under MSan), which merged before this test existed. The cost is the sanitizer's, not a random setting: every query pins its join algorithm, and the duration follows the test's position in the job (127 s early in a job, 230-402 s late). ASan, UBSan, TSan, debug and release keep running it, and in every debug/sanitizer build `HashedJoinKey::buildRange` still asserts each batched key against the row-by-row one. MSan stress jobs ignore `no-msan`, and `05508_join_hashed_keys_prefetch` (mean 61.9 s) stays under MSan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MSan stateless jobs are the slowest functional-test jobs in CI and sit right at the edge of the 9000 s job timeout. In a recent run the private
Stateless tests (amd_msan, distributed cache, meta in keeper, s3 storage, sequential, 2/2)job spent 8324 s of its 9000 s budget on tests and was then killed during teardown, even though all 526 tests had passed.MSan is ~5.8× slower than release on the same tests, and the cost is concentrated in a long tail: under MSan, 8 tests take over 180 s each, and the 30 slowest account for ~48% of a sequential shard's runtime.
This tags every functional test whose mean duration under MSan exceeds 60 s with
no-msan, except three tests that would otherwise lose all - or all memory-safety - sanitizer coverage.How the set was chosen
From
play.clickhouse.com, over the public MSan stateless checks (Stateless tests (amd_msan, parallel, N/M)andStateless tests (amd_msan, sequential, N/2), excluding the flaky-check and selected-tests flavors; until 2026-09-11 these checks carried aWasmEdgelabel, which the pattern below matches as well):351 tests matched. 30 of them no longer exist in
master(reverted, split into smaller tests, or removed), leaving 321. One of those,04062_text_index_json_all_values_ghdata, already carriedno-msan; three more remain under MSan to retain their sanitizer coverage, which left 317 files. Since then a further 10 of the tagged tests have been deleted frommaster(removed with the sharded aggregator, migrated to integration tests, or dropped along with the old analyzer), and those deletions were accepted when mergingmaster. Two more have since dropped out:masteraddedno-msanto00974_query_profileritself, and04757_schema_inference_cache_key_settingswas split into five per-carrier files, so the measured average no longer describes the remaining shard. Re-running the selection query on 2026-09-17 over the last 30 days showed that 27 of the tagged tests had drifted to an average at or below 60 s (from 6.7 s for04040_tpc_h_q05up to 60.0 s for04031_row_binary_with_names_columns_input_format), sono-msanwas dropped from them again. On 2026-09-23masteraddedno-msanto01721_join_implicit_cast_longitself (with its own rationale), so it dropped out of the diff too. On 2026-09-27 the query was re-run once more: since 2026-09-06 the checks run without theWasmEdgelabel and are markedly faster under MSan (01647_clickhouse_local_hungwent from ~102 s to ~52 s, while03988_cached_read_big_atstayed at ~410 s), so 93 more of the tagged tests had dropped to between 30.2 s (04616_json_lazy_type_hints_key_safety) and 59.9 s (04303_clickhouse_disks_du) and lost theirno-msanagain. On 2026-10-03 the query was re-run again: 31 tagged tests had dropped to at or below 60 s (e.g.02561_null_as_default_more_formats) and lostno-msan, while 51 tests had risen above 60 s or were newly added (e.g. the three02346_text_index_function_like*tests) and gained it. On 2026-10-09, after mergingmaster, the query was re-run once more: 16 tagged tests had dropped to at or below 60 s (from 47.1 s for02515_cleanup_async_insert_block_idsto 59.9 s for00834_kill_mutation_replicated_zookeeper) and lostno-msan, while 25 untagged tests had risen above 60 s or were newly added (e.g.04820_block_nested_loop_join_anyat 80.5 s) and gained it. On 2026-10-11, after mergingmasteragain, the query was re-run over the fixed 30-day window ending 2026-10-11 00:00:00 UTC:05099_ast_fuzzer_oracle_view_definitionhad been removed frommaster, 2 tagged tests had dropped to at or below 60 s (05055_string_filters_during_scan_parquetat 59.2 s and01076_parallel_alter_replicated_zookeeperat 59.0 s) and lostno-msan, while 8 untagged tests had risen above 60 s or were newly added (from 158.5 s for05217_aggregation_in_order_fixed_keysdown to 60.2 s for05259_mutation_of_part_without_table_columns, including03772_temporary_files_codecat 62.5 s) and gained it. That leaves 218 files changing here, all above 60 s in the 2026-10-11 data. On 2026-10-16, after mergingmasteragain, three more dropped out:masteraddedno-msanitself (with its own rationale) to01169_old_alter_partition_isolation_stress,04238_alter_rename_column_merge_raceand05240_keycondition_dag_timezone_attribute_pruning.00564_versioned_collapsing_merge_treewas also left untouched, because #125263 cut its inserts five-fold, and changing it made the flaky check run it over the 180 s limit withs3 storage. That leaves 213 files changing here. On 2026-10-18, after mergingmasteragain,no-msanwas also dropped from four tests whose fixturesmastersped up after the 2026-10-11 snapshot (#125263, #125795): over successfulmasterruns from 2026-10-15 12:00 to 2026-10-16 12:00 UTC,03173_row_binary_and_native_with_binary_encoded_typesaverages 4.7 s,04073_parallel_replicas_in_order_splits16.0 s,00223_shard_distributed_aggregation_memory_efficient46.3 s and04143_low_cardinality_single_dict_read_amplification50.2 s under MSan. That leaves 209 files changing here. Averages close to 60 s keep drifting from run to run, so this is a snapshot of the rule on a fixed date. Besides00180_no_seek_avoiding_when_reading_from_cache(below), two other tests above the cutoff are left under MSan for coverage:02354_vector_search_expansion_searchalready skips every other sanitizer, and04093_msan_fiber_distributed_false_positiveexists specifically to test MSan. The third of them,00180_no_seek_avoiding_when_reading_from_cache(75.9 s mean under MSan), was added after review: it already carriesno-asan, sono-msanwould have left the filesystem-cache read path without any memory-safety sanitizer, and its runtime is at the low end of the tagged set. OnlyOKruns are counted, so timeouts and failures do not inflate the averages.Initial expected effect
The following estimates were calculated before retaining the two sanitizer-coverage tests.
25 slowest of the tagged tests
03988_cached_read_big_at03008_deduplication_insert_several_blocks_replicated03008_deduplication_several_mv_into_one_table_nonreplicated03008_deduplication_insert_several_blocks_nonreplicated04039_merge_tree_snapshot_teardown_race01195_formats_diagnostic_info02475_bson_each_row_format00626_replace_partition_from_table_zookeeper01019_alter_materialized_view_atomic04062_text_index_json_all_values_ghdata01721_join_implicit_cast_long00746_sql_fuzzy03755_large_primary_key_explain02943_variant_type_with_different_local_and_global_order02448_clone_replica_lost_part02372_analyzer_join04327_cluster_functions_huge_num_streams_no_crash01721_join_implicit_cast_long_oldanalyzer01079_bad_alters_zookeeper_long01747_system_session_log_long03208_array_of_json_read_subcolumns_100429_long_http_bufferization04411_deep_nested_field_to_type01383_log_broken_table03326_protobuf_schemas_race(Averages and run counts in this table are from the original selection. 209 test files are changed in total; the full list is the diff.)
Trade-off
A large share of these are the ZooKeeper, replication, mutation and race tests — precisely where MSan is most likely to find real uninitialized-memory bugs. They continue to run under ASan, UBSan and TSan, but this is a genuine reduction in MSan coverage rather than a pure win. An alternative that keeps the coverage is duration-aware sharding of the sequential jobs: the split is currently
crc32(test filename) % total_batches, which gave one recent shard 8248 s against its sibling's 5514 s (1.50×), so balancing alone would have reclaimed ~23 min on the shard that timed out.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/115050]
Version info
26.11.1.955-master(included in26.11and later)