Repository navigation
Randomize default compression codec in stateless tests - #108093
Conversation
Add randomization of the default column compression codec to the stateless test runner, cycling MergeTree tables (for columns without an explicit CODEC) through LZ4, ZSTD(1) and ZSTD(3) via the per-table `default_compression_codec` MergeTree setting. Codec values contain parentheses, which the two test execution paths treat oppositely: `.sql` tests embed the options into a shell command line (so the value must be shell-quoted, otherwise the parentheses are a syntax error), while `.sh` tests expand `CLICKHOUSE_CLIENT_OPT` unquoted via `$CLICKHOUSE_CLIENT` (so the value must stay bare, otherwise the quotes are passed through to the client literally). To support both, `cli_format_settings` gains a `shell_quote` option (using `shlex.quote`, which only quotes values that actually need it, leaving every existing setting untouched). `add_effective_settings` now keeps bare values in the env var and shell-quotes the values it embeds into the `.sql` command line; the human-facing reproduction strings are shell-quoted too so they can be copy-pasted. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [1e3be0c] Summary: ✅ AI ReviewSummaryThis PR moves stateless-test coverage of Findings
Tests
Final VerdictStatus: Minimum required action: restore the global no-random opt-out for the server-level |
The codec randomization added `--default_compression_codec ZSTD(1)`/`ZSTD(3)`
to the client options. For `.sh` tests these go through the
`CLICKHOUSE_CLIENT_OPT` env var, which is expanded unquoted via
`$CLICKHOUSE_CLIENT`; some `.sh` tests re-parse that string through a second
shell (e.g. perl `qx{}`, `eval`, `bash -c`), where the bare parentheses are a
shell syntax error (`sh: 1: Syntax error: "(" unexpected`). No single env-var
representation survives both the single-expansion case (needs bare) and the
re-parse case (needs quoting).
So `cli_format_settings` now drops shell-unsafe values from the bare env var
(`omit_unsafe`) while still shell-quoting them on the `.sql` command-line path.
`.sql` tests keep per-test codec randomization; a `.sh` test that needs a
specific codec sets it explicitly in SQL.
Also pin `default_compression_codec='LZ4'` in
`02028_system_data_skipping_indices_size`: skip index substreams are compressed
with the default codec, so their reported compressed size depends on it.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the per-test CLI approach with a server-level <compression> config
override generated in tests/config/install.sh, randomized across LZ4, ZSTD(1)
and ZSTD(3). The per-test approach passed `--default_compression_codec ZSTD(3)`
through the client options; for .sh tests these go through CLICKHOUSE_CLIENT_OPT,
which is expanded unquoted and sometimes re-parsed through a second shell (perl
`qx{}`, `eval`, `bash -c`), where the bare parentheses are a shell syntax error.
No single env-var representation survives both uses.
The server <compression> override has no such problem: it is plain XML config,
applies to .sql and .sh tests alike, and matches how the default codec actually
works. A test that needs a specific codec pins it with
`SETTINGS default_compression_codec = '...'` (which overrides the server default,
since ClientBase only injects settings not already present).
This reverts the tests/clickhouse-test changes from the earlier commits on this
branch. The 02028 pin is kept (it is still needed under this approach).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The server-level <compression> override (install.sh) randomizes the default codec for ALL tests, bypassing the no-random-merge-tree-settings / no-random-settings opt-outs. This broke the Fast test (a gate) on 16 codec-sensitive tests. clickhouse-test now injects `default_compression_codec=LZ4` for any test tagged no-random-merge-tree-settings or no-random-settings (skipping SHOW CREATE tests, where it would change the printed definition). LZ4 has no shell metacharacters, so it is safe in CLICKHOUSE_CLIENT_OPT for .sh tests. This pins all such tests back to the historical default — what "no randomization" should mean — and auto-fixes the ~255 opted-out tests, including 9 of the 16 Fast test failures. The 7 remaining (untagged) failures assert codec-dependent output (index/column sizes, mark offsets, statistics-based prewhere order). They run cleanly on master under per-test MergeTree randomization, so only the codec affects them — pinned inline with `SETTINGS default_compression_codec = 'LZ4'`: 01465 (+ SHOW CREATE reference), 02864, 03164, 03261, 04114, 04115; 03276 (a .sql.j2 that echoes its CREATE text, so an inline pin would break the Jinja/SQL quoting) gets the no-random-merge-tree-settings tag instead. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| # shell metacharacters, so it is safe in CLICKHOUSE_CLIENT_OPT for .sh tests. | ||
| # SHOW CREATE tests are skipped: the injected setting would change their output. | ||
| if ( | ||
| (has_no_random_settings_tag or has_no_random_merge_tree_settings_tag) |
There was a problem hiding this comment.
--no-random-settings and --no-random-merge-tree-settings no longer disable this randomization. The new server <compression> value is chosen in install.sh, but this pin only covers tests that carry no-random tags; a global opt-out (the Fast test command passes both flags, and the diagnostics path reruns with {} as "without randomized settings") still leaves untagged tables using random ZSTD(1) / ZSTD(3) unless each test was manually pinned. That breaks the opt-out/repro contract and can keep codec-sensitive failures in the supposedly non-random run. Please include args.no_random_settings / args.no_random_merge_tree_settings in this condition, or gate the generated config so those modes restore LZ4 globally.
The codec injection for no-random-* tests uses --allow_merge_tree_settings, which makes the client rewrite CREATE ... MergeTree queries (adding the SETTINGS). That broke tagged tests that observe the query text — `01600_log_queries_with_extensive_info` (reads system.query_log normalized_query_hash) — or whose CREATE reparse changes semantics — `02293_compatibility_ignore_auto_increment_in_create_table` (the client-side reparse no longer raises the expected SYNTAX_ERROR for AUTO_INCREMENT). Such tests are not codec-sensitive (they pass under the randomized server default, which is invisible to query text), so the injection now skips tests matching `show create | create_table_query | normalized_query | auto_increment`. Tests that read system.query_log only for metrics (e.g. 03277, 03634) are not excluded and keep the pin. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…42/03278 The <compression> server override broke `clickhouse local`: ConnectionParameters reads the top-level `<compression>` config key as a connection-level boolean, so a codec selector there fails with "Cannot convert to boolean: zstd 3" — this broke the "Scraping system tables" step (clickhouse-local --config-file=.../config.xml) in every stateless flavor. Set the randomized default codec through the `default_compression_codec` MergeTree setting in the <merge_tree> config section instead. Verified: clickhouse-local no longer crashes, columns are compressed with the chosen codec, and an inline `SETTINGS default_compression_codec = '...'` still overrides it. Also pin the two genuine codec-sensitive stateless failures: - 03278_json_subcolumns_in_skipping_indexes: JSON sibling of 03276, same .sql.j2 that echoes its CREATE text, so tagged no-random-merge-tree-settings (pinned via injection). - 02842_move_pk_to_end_of_prewhere: cost-based prewhere reordering depends on column sizes, which depend on the codec; pinned to LZ4 (its diagnosis even confirmed it fails "without randomized settings", i.e. it is the server codec). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| (has_no_random_settings_tag or has_no_random_merge_tree_settings_tag) | ||
| and not self.test_observes_create_query_text() | ||
| and "default_compression_codec" not in self.effective_merge_tree_settings | ||
| ): |
There was a problem hiding this comment.
A long comment doesn't help understanding what is going on here.
Three variables with dedicated one-line comments would be much more valuable.
Full stateless suite (after the <merge_tree> fix) surfaced exactly three codec-sensitive failures across all flavors; all pinned to LZ4: - 02864_statistics_usage: prewhere condition order falls back to cost-based (column sizes) after statistics are dropped; sizes depend on the codec. - 03783_autopr_dataflow_cache_reuse_qcc: the automatic-parallel-replicas decision compares estimated table bytes against a 1Mi threshold, so a smaller (ZSTD) codec flips pr_used. Diagnosis confirmed it fails "without randomized settings" (i.e. the server default codec). - 03291_json_big_structure_deserialization: a `long` test using 128-byte compress blocks; ZSTD on tiny blocks is much slower and timed out under tsan (the rerun passed). Pin to LZ4 to keep it fast and deterministic. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Investigation of the "Server died" in the amd_debug flaky check: it is NOT an OOM/crash. The server-wide memory limit (max_server_memory_usage, 53.8 GiB) was never exceeded, dmesg shows no kernel OOM, there is no fatal signal/abort, and the server shut down gracefully — the harness restarted it because `SELECT 1` (liveness) timed out for ~60s. The 354 MEMORY_LIMIT_EXCEEDED entries are per-query graceful rejections of background distributed log-export sends. Root cause: this PR modifies 03291, which pulls it into the flaky check (each modified test is rerun ~40x). 03291 stores a big JSON column in 128-byte compress blocks, and a single `select json.a` took ~3000s (TOO_SLOW) under the debug build; running it ~40x saturated the server and tripped the liveness timeout. Tag it no-flaky-check (it is already `long`). The LZ4 pin added earlier keeps the regular single run fast (a random ZSTD makes the tiny-block JSON read even slower). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@groeneai, provide a fix for |
|
@alexey-milovidov fix in #108338 (targets this branch).
|
…ompression-codec # Conflicts: # tests/config/install.sh
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 472 line(s), 24 function(s) across 134 file(s) · Details Top files
|
…t-compression-codec Randomize default compression codec in stateless tests
Add randomization of the default column compression codec to the stateless test runner (
clickhouse-test). For every randomizedMergeTreetable, columns without an explicitCODECnow get a default codec randomly chosen amongLZ4,ZSTD(1)andZSTD(3), via the per-tabledefault_compression_codecMergeTreesetting. This exercises more of the compression code paths across the existing test suite.Codec values contain parentheses, which the two test execution paths treat oppositely:
.sqltests embed the client options into a shell command line (so the value must be shell-quoted, otherwise the parentheses are a syntax error), while.shtests expandCLICKHOUSE_CLIENT_OPTunquoted via$CLICKHOUSE_CLIENT(so the value must stay bare, otherwise the quotes are passed to the client literally). To support both,cli_format_settingsgains ashell_quoteoption (usingshlex.quote, which only quotes values that actually need it, so every existing setting is unchanged);add_effective_settingskeeps bare values in the env var and shell-quotes the values it embeds into the.sqlcommand line. The human-facing reproduction strings are shell-quoted too, so they can be copy-pasted.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Randomize the default compression codec (
LZ4,ZSTD(1),ZSTD(3)) in stateless tests.🤖 Generated with Claude Code
Version info
26.7.1.202(included in26.7and later)