Skip to content

Upgrade check: honor storage skip tags by forwarding --s3-storage / --encrypted-storage - #111772

Merged
Fgrtue merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/upgrade-check-honor-object-storage-tags
Jul 27, 2026
Merged

Fgrtue merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/upgrade-check-honor-object-storage-tags

Conversation

@groeneai

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

The Upgrade check configures the server with object storage as the default MergeTree policy (configure --s3-storage in upgrade_runner.sh) and randomly enables encrypted storage, but invokes clickhouse-test without --s3-storage and never forwards --encrypted-storage. So clickhouse-test runs with args.s3_storage / args.encrypted_storage = False and ignores its storage skip tags (no-object-storage, no-s3-storage, no-encrypted-storage) — those branches in should_skip_test fire only when the matching argument is set. Tests that declare themselves incompatible with the configured backend then run against an unsupported one.

This is what produces the Upgrade check (amd_release) failures reported on #110607 and #110084:

void DB::AsyncLoader::worker(Pool &): Code: 27. DB::Exception: Cannot parse input: expected '\n' before: 'version: 1\nstoring_version: 0\ncreation_tid: (2, 33, ...)'
MergeTreeData: Failed to read version metadata for part all_1_2_2_1: Code: 27. ...

Reports: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110607&sha=8533d1bba003f8bf2a7a207ed25d04b4d02bce48&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 , https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110084&sha=028f6edefc3596c261f910f0f8f57d2ebe9d3ce7&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29

The four 04063/04241/04417/04500_part_loading_tree_rollback_* tests are all tagged no-object-storage. They fabricate a raw plaintext txn_version.txt in a part directory (valid only on a local disk). On the object-storage-default server the part-dir file must be DiskObjectStorageMetadata, so the raw file is unreadable and PartLoadingTree::add (from #100992) reports CORRUPTED_DATA / Code: 27 at the test's own ATTACH (single run, no restart). --upgrade-check implies --fake-drop, so the corrupt part survives into the new server, which logs the same error at part load. #111055 / #111661 hardened these tests on master, but the Upgrade check runs the frozen previous-release test suite, so those changes cannot reach it.

The fix forwards --s3-storage (in the clickhouse-test command) and --encrypted-storage (mirroring the coin flip, via stress.py) so clickhouse-test matches the server's actual configuration and skips incompatible tests, exactly as the regular stress runner already does.

Note: this skips storage-incompatible tests in the Upgrade check that previously ran on an unsupported backend (~130 no-object-storage tests in the previous release), which is correct since the server is object-storage-default. That is a CI coverage trade-off in your area, so please redirect if you would prefer a narrower scope.

…-encrypted-storage

The Upgrade check configures the server with object storage as the default
MergeTree policy (configure --s3-storage) and randomly enables encrypted
storage, but ran clickhouse-test without --s3-storage and never forwarded
--encrypted-storage. So clickhouse-test had args.s3_storage / args.encrypted_storage
= False and ignored its storage skip tags (no-object-storage, no-s3-storage,
no-encrypted-storage): those branches in should_skip_test fire only when the
matching argument is set. Tests declared incompatible with the configured
backend then ran on an unsupported one.

This produced the Upgrade check (amd_release) Code 27 / Code 246 failures on
the four 04063/04241/04417/04500_part_loading_tree_rollback_* tests (all tagged
no-object-storage): they fabricate a raw plaintext txn_version.txt in a part
directory (valid only on a local disk), which is unreadable on an object-storage
disk, so PartLoadingTree::add (from ClickHouse#100992) reports CORRUPTED_DATA at the test's
own ATTACH. With --upgrade-check (which implies --fake-drop) the corrupt part
survives into the new server, which logs the parse error at part load.
ClickHouse#111055 / ClickHouse#111661 hardened these tests on master, but the Upgrade check runs the
frozen previous-release test suite, so those changes cannot reach it.

Forward --s3-storage (in the clickhouse-test command) and --encrypted-storage
(mirroring the coin flip, via stress.py) so clickhouse-test matches the server's
actual configuration and skips incompatible tests, as the regular stress runner
already does.

Related: ClickHouse#111053

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. .scratch/prove_skip.py exercises clickhouse-test's own parse_tags_from_line + should_skip_test predicates against the real test files: without the flags the 4 rollback tests (and the encrypted-only 03277) are NOT skipped (they RUN); with them they are skipped. Deterministic, both directions. Also confirmed in CI logs: single old-server run (CREATE -> DETACH -> ATTACH -> Code 246, no restart).
b Root cause explained? Yes. The Upgrade check configures the server object-storage-default (configure --s3-storage) and randomly enables encrypted storage, but invokes clickhouse-test without --s3-storage and never forwards --encrypted-storage, so args.s3_storage/args.encrypted_storage are False and the no-object-storage/no-encrypted-storage skip branches never fire. The rollback tests then run on object storage, where their raw plaintext txn_version.txt is unreadable -> PartLoadingTree::add (from #100992) reports CORRUPTED_DATA / Code 27.
c Fix matches root cause? Yes. Forwards --s3-storage (in the clickhouse-test command) and --encrypted-storage (via stress.py) so clickhouse-test's storage state matches the server and honors the skip tags. Targets the mechanism (ignored tags), not the symptom (the error message).
d Test intent preserved / new tests added? Yes. No test weakened or edited. The incompatible tests are SKIPPED in the Upgrade check (where they cannot run correctly); their coverage is unchanged in the functional-test jobs.
e Both directions demonstrated? Yes. prove_skip.py: all 4 rollback tests + the encrypted-only 03277 go RUN (without flag) -> SKIP (with flag).
f Fix is general across code paths? Yes. Fixes ALL no-object-storage/no-s3-storage/no-encrypted-storage tests wrongly running in the Upgrade check, not just the 4 rollback tests. Both storage-tag classes covered (object + encrypted).
g Fix generalizes across inputs? Yes. The flags govern every storage-incompatibility tag, not one test/part/type. The sibling encrypted-storage gap flagged in review is fixed in the same PR (one concern: storage-tag forwarding).
h Backward compatible? N/A. CI test-runner change only (tests/docker_scripts/upgrade_runner.sh); no server behavior, setting default, or on-disk format change.
i Invariants and contracts preserved? Yes. --s3-storage is a client-side clickhouse-test flag independent of the server-side configure --s3-storage; its only other effect (no_random_settings on non-release builds) is already implied by the Upgrade check's --no-random-settings. --encrypted-storage is forwarded exactly as the regular stress runner already does (stress_runner.sh). No server contract touched.

Session id: cron:clickhouse-author-slot-5:20260724-095100

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review — adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 findings across the initial pass + delta recheck; bounded: 1 full pass + 1 fix round + 1 delta recheck).

# Sev Finding Verdict Evidence / action
1 ⚠️ The encrypted-storage half of the Upgrade check still runs no-encrypted-storage tests against an unsupported backend (--encrypted-storage was never forwarded). AGREE — fixed @ 0dc9d1e Captured the encrypted coin flip in use_encrypted_storage and forwarded --encrypted-storage "$use_encrypted_storage" to the stress invocation, mirroring stress_runner.sh. Delta recheck confirmed the fix (finding dropped).
2 ⚠️ Lacks live end-to-end evidence that both flags cause the intended frozen-release tests to be skipped in an actual Upgrade-check job. DEFERRED Deterministic proof against clickhouse-test's verbatim skip predicates provided for both dimensions; reviewer confirms "the forwarding path is structurally correct." A live Upgrade-check run needs docker + previous-release packages (infeasible here); the genuine end-to-end confirmation is produced by this PR's own Upgrade check in CI.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-author-slot-5:20260724-095100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus - could you review? The Upgrade check configures the server object-storage-default but ran clickhouse-test without --s3-storage (and never forwarded --encrypted-storage), so no-object-storage/no-encrypted-storage tests ran on an unsupported backend. This forwards both flags in tests/docker_scripts/upgrade_runner.sh so those tests are skipped, fixing the Code 27 txn_version.txt failures reported on #110607 and #110084.

@clickhouse-gh

clickhouse-gh Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ca6cc81]

Summary: ✅


AI Review

Summary

This PR makes the Upgrade check pass the actual storage backend into clickhouse-test, so the frozen previous-release suite honors no-object-storage, no-s3-storage, and no-encrypted-storage tags instead of running backend-incompatible tests on the object-storage configuration. I found no remaining correctness or contract issues in the forwarding path after tracing upgrade_runner.sh, stress.py, and clickhouse-test, and the current Praktika report is green for this PR.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 25, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 0dc9d1e

The Upgrade check (amd_release) target of this PR (the Code: 27 Cannot parse input: expected '\n' before: 'version: 1 storing_version: 0 ...' txn_version.txt parse error) is CLEARED on this run: 0 occurrences. The --s3-storage / --encrypted-storage forwarding makes clickhouse-test skip the no-object-storage / no-encrypted-storage backup tests in the previous-release tree, so the corrupt part is no longer produced. This confirms end-to-end the deterministic skip proof deferred at PR open.

Two remaining reds, neither PR-caused (this PR touches only tests/docker_scripts/upgrade_runner.sh):

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log (system.metric_log rotation, Code 229 QUERY_IS_TOO_LARGE) metric_log metadata exceeds max_query_size on rotation #111703 (merged 2026-07-24) — merged master into this branch @ ca6cc81 to pick it up
Stress test (amd_debug) / Logical error: Inconsistent KeyCondition behavior trunk bug (8 master + 101 unrelated PRs / 30d) #109023 (ours, open)

I merged current master (@ ca6cc81) to pick up #111703, which resolves the system.metric_log rotation error. CI is re-running on the merged head.

Session id: cron:our-pr-ci-monitor:20260725-020000

@alexey-milovidov alexey-milovidov 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.

Good.

@alexey-milovidov alexey-milovidov self-assigned this Jul 26, 2026
@Fgrtue
Fgrtue added this pull request to the merge queue Jul 27, 2026
Merged via the queue into ClickHouse:master with commit 072f21d Jul 27, 2026
178 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 27, 2026
alexey-milovidov added a commit to groeneai/ClickHouse that referenced this pull request Jul 27, 2026
…owif-leaks

Conflict in `tests/docker_scripts/upgrade_runner.sh`: master merged ClickHouse#111772,
which forwards `--s3-storage` / `--encrypted-storage` to `clickhouse-test` in the
upgrade check — the same root-cause fix this branch carried, implemented in the
canonical way (the coin flip is mirrored into `stress.py` via `--encrypted-storage`
instead of embedding both flags in `--test-cmd`). Resolved by taking master's
plumbing and dropping this branch's now-redundant `test_opts` variant; the two are
behaviourally equivalent.

What remains unique to this branch is the benign-error allowlist for the encrypted
`Backup`-engine leftovers (Code 697 `CANNOT_RESTORE_TO_NONENCRYPTED_DISK` and the
follow-up `Detaching broken part` line), which is still needed as defense in depth
for previous-release trees that predate the `no-encrypted-storage` tags. Those
`grep -av` entries auto-merged alongside master's own additions.
alexey-milovidov added a commit that referenced this pull request Jul 28, 2026
Pulls in the `Upgrade check` fix #111772 (forward `--s3-storage` so the
`part_loading_tree_rollback` tests honor their storage skip tags), which
accounts for the `Upgrade check (amd_release)` red on the previous head.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 28, 2026
…ata-bin-leak

One conflict, in tests/docker_scripts/upgrade_runner.sh: the master side is
ClickHouse#111772, which forwards --s3-storage and --encrypted-storage on the same
`stress` invocation this branch adds --skip-func-tests to. Resolved keep-both:
master's quoted --test-cmd (with --s3-storage) and its --encrypted-storage coin
flip are retained verbatim, --skip-func-tests "--skip 02255_..." is added, and
both comment blocks are kept because they explain different things (storage-tag
forwarding vs. why the skip must live in the runner rather than the test file).

ClickHouse#111772 does not supersede the skip: the previous-release copy of
02255_broken_parts_chain_on_start.sh is tagged only long, zookeeper,
no-shared-merge-tree, so forwarding the storage flags does not skip it.
pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request Jul 28, 2026
The five part_loading_tree_rollback tests (04063/04241/04417/04500/04624)
fabricate MergeTree parts out-of-band with a raw plaintext txn_version.txt
and remove them via a path derived from the `default` disk. Both steps only
work when the table lives on the local default disk, but harnesses that set
an object-storage default MergeTree policy without passing --s3-storage to
clickhouse-test (the Stress check, and the Upgrade check before ClickHouse#111772) run
these tests anyway: the raw fixture file does not parse as object-storage
metadata (Code 27 -> CORRUPTED_DATA on attach), and the uuid-based recovery
rm -rf misses the real data path. Pinning storage_policy = 'default' makes
the fixture and the recovery path correct on any server default policy and
restores the tests' intended coverage on object-storage-default Stress runs.

Related: ClickHouse#111053
pull Bot pushed a commit to weiyilai/ClickHouse that referenced this pull request Aug 9, 2026
…zure-blob-storage

stress_runner.sh ran stress.py without --test-cmd, so stress.py used its default
/usr/bin/clickhouse-test (ci/jobs/scripts/stress/stress.py:714) and clickhouse-test
was never told which storage backend the server actually uses. Its storage skip tags
are gated on exactly that knowledge (tests/clickhouse-test:2985-3001 requires
args.s3_storage / args.azure_blob_storage, set only by the --s3-storage /
--azure-blob-storage flags), so no-object-storage (150 tests), no-s3-storage (36) and
no-azure-blob-storage (53) were inert in every Stress run. The two fields are read by
separate gates and the runner draws one backend, so an s3 run should skip 177 of them
(150 + 36, 9 carry both) and an azure run 203 (150 + 53, no overlap). A fourth gate
exists for no-object-storage-with-slow-build, but no test carries that tag today.

Meanwhile stress_runner.sh:103-121 puts the server on object storage even for a
flavour whose check name mentions neither s3 nor azure, via random=$((RANDOM % 3)):
1 selects s3_cache and exports USE_S3_STORAGE_FOR_MERGE_TREE=1, 2 selects
azure_cache. So 2 of 3 runs of a "non-s3" flavour are object-storage runs, which is
why the failures below are mostly on flavours with no s3 in the name.

04630_merge_over_stale_packed_tmp_dir carries no-object-storage because it copies a
live part directory with a shell cp -r to simulate an interrupted merge. On an
object-storage disk those files are metadata whose blob reference count lives inside
the metadata file (DiskObjectStorageMetadata.h:24) and is bumped only by ClickHouse's
own hardlink path (MetadataStorageFromDiskTransactionOperations.cpp:370), so the copy
claims ref_count == 0. When the merge legitimately reclaims that leftover
(MergeTreeData::reclaimStaleTemporaryPartDirectory -> removeSharedRecursive), the
unlink decides blob deletion from that stale count and deletes the remote blob still
referenced by the live active part all_1_1_0. The merge, OPTIMIZE, three SELECTs and
CHECK TABLE then all fail on that one key, which is what the harness reports as
"S3_ERROR No such key thrown". Measured over 14 days: 10 rows across 10 unrelated
PRs, all on S3 (cached_s3 / cached_s3_encrypted), 5 Stress flavours, 0 on master.

Forward the backend the runner already chose, at the one place that knows it. Same
shape as the sibling upgrade_runner.sh:134 (ClickHouse#111772), generalized only where it must
be: upgrade_runner hardcodes --s3-storage because it hardcodes the policy, while
stress_runner picks s3 or azure at runtime, so the flag follows the environment. When
neither variable is set the composed command is byte-identical to stress.py's own
default, so local-policy runs are unchanged.

Validated with MinIO against an object-storage default MergeTree policy: without the
flag the test runs and FAILs 3/3; with --s3-storage it is SKIPPED (reason
object-storage) 3/3 with zero no-such-key errors in the server log; and on the local
default policy it PASSes 3/3, which shows the fixture reaches the deletion path only
on object storage. The composed --test-cmd was asserted in all three environment
states, and stress.py was confirmed to forward the flag into both the smoke and the
stress commands of every worker.

Two intended consequences of making the tags effective: a Stress run that draws
object storage now SKIPs the tests declared incompatible with that backend instead of
silently mis-running them, so its test count drops by up to 177 on an s3 draw and 203
on an azure draw; and only amd_debug / arm_debug runs that draw s3 lose settings
randomization (tests/clickhouse-test:5828), because every sanitizer and release
flavour builds with CMAKE_BUILD_TYPE=None, which CMakeLists.txt:67-69 rewrites to
RelWithDebInfo and clickhouse-test maps to BuildFlags.RELEASE. That combination is
already shipped and accepted for Stateless tests (amd_debug, ..., s3 storage, ...).
Additionally --encrypted-storage, today silently disabled in this path by
tests/clickhouse-test:7135 because no storage flag is passed, starts taking effect.

Related: ClickHouse#111053
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 manual approve Manual approve required to run CI pr-ci 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