Repository navigation
Keep the default compression codec stable across the upgrade check's restart - #121249
Conversation
…restart
Upgrade check (amd_release) has gone red on 5 unrelated PRs in 90 days (0
master rows) with
Code: 40 ... Checksums of parts don't match: hash of uncompressed files
doesn't match (X vs Y), uncompressed hash of compressed files doesn't
match (A vs B). (CHECKSUM_DOESNT_MATCH)
followed by a refetch from the peer. The server self-heals, but the <Error>
line is logged and no allow-list entry covers it, so the job fails.
tests/config/install.sh draws the server-level default_compression_codec
from ("LZ4" "ZSTD(1)" "ZSTD(3)") with $RANDOM on every configure call, and
tests/docker_scripts/upgrade_runner.sh calls configure twice over one data
directory: once for the previous-release server and once for the new one.
The two draws are independent, so with probability 2/3 the two servers of a
single job write parts under different codecs. Because it is a server
default it is not persisted into a table's CREATE, so every write resolves
it from the running server. A part the previous-release server committed to
ZooKeeper is then no longer byte-identical when the new server re-merges or
re-mutates it, and checkPartChecksumsAndCommit rejects it. This is reason 2
of the error message's own list ("Using another compression method"), so the
product is behaving as designed; the harness is what is unfaithful, since a
real in-place upgrade does not re-roll the server's compression codec.
Both compared aggregates are codec-sensitive, which is why the message
carries both clauses. serializeStatisticsPacked compresses each per-column
statistics blob with the part's codec but registers the container with only
file_size/file_hash, leaving is_compressed false, so codec-dependent raw
bytes are compared as uncompressed content. Separately, a mark encodes
offset_in_compressed_file, so the marks' uncompressed content embeds the
compressed layout of the data. Measured by turning statistics off: the
uncompressed-files aggregate then stops diverging while the other still
does, which attributes one bucket to statistics.packed and the other to the
marks. For a Wide part both move once a column's data spans more than one
compressed block; below that every mark offset is 0.
install.sh gains a --default-compression-codec option, validated against
the same array that defines the legal values and failing closed on an
invalid, empty or missing value; upgrade_runner.sh reads back the codec its
previous-release configure drew and passes it to the second configure only
(not through configure_opts, which both calls share). If the read-back is
empty the runner writes a FAIL row and exits. The runner then re-reads the
generated config after the second configure and fails the job if the
upgraded server's codec differs, so a pin that stops being applied cannot
quietly restore the randomized condition.
An option rather than an environment variable because b41d0c5 moved
this runner off env vars onto install.sh options, and the option makes the
requirement legible at the site a future part-format randomization would be
added. Per-job randomization is preserved, all three codecs are still
covered across runs, and reads are unaffected because every part records
its own codec in default_compression_codec.txt.
Deliberately not an allow-list entry for this message: that would also hide
a genuine non-deterministic-merge regression and the separate
statistics-format divergence, which is the signal worth keeping. After this
change that sub-case presents with only the "hash of uncompressed files"
clause, so it becomes cleanly attributable.
Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Two rounds. Round 1: an independent model (engine: codex) raised 1 finding, plus my own cold pass over
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260920-224900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260920-223300 |
|
Workflow [PR], commit [ba97606] Summary: ✅ AI ReviewSummaryThis PR fixes the Final Verdict
LLVM Coverage ReportMeasured on commit ba97606.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +151 lines in 46 files (-194 lines lost coverage) · Details |
a49c2b6
upgrade_runner.sh calls configure() twice over one embedded Keeper and data directory, and with RANDOMIZE_KEEPER_FEATURE_FLAGS=1 each call draws check_not_exists, create_if_not_exists and remove_recursive again, independently. When create_if_not_exists goes from 1 to 0, a coordinated refreshable view created during the stress phase (04811's APPEND view in a database recreated as Replicated) is attached against a Keeper that lost the flag, and RefreshTask stops it by design, logging an <Error> that the upgrade log scan reports. This failed the check on 3 unrelated PRs in 30 days (ClickHouse#118372, ClickHouse#117784, ClickHouse#114812); all 3 job logs show the 1 -> 0 flip. A real in-place upgrade does not downgrade its Keeper, so carry the flags the previous-release configure() drew into the upgraded server's keeper_port.xml and fail the job if they still differ, the same shape as the codec carry-over of ClickHouse#121249. Every job still draws random flags. Validated locally: the real code extracted from both scripts, run 2000 times in the CI image, restores the first draw 2000/2000 with no FAIL row; with the restore removed the new check fails 1765/2000. On a master build, restarting with create_if_not_exists turned off logs exactly the CI line, and restarting with the flags unchanged logs nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
Upgrade checkCI job now uses the same randomizeddefault_compression_codecfor both servers it boots, instead of drawing it again for the new one.Description
Upgrade check (amd_release)has gone red on 5 unrelated PRs in 90 days (0 master rows) withCode: 40 ... Checksums of parts don't match ... (CHECKSUM_DOESNT_MATCH), then a refetch from the peer.The product is not at fault: two servers resolving different
default_compression_codecvalues is supported, and it is reason 2 of the error's own list ("Using another compression method"). The harness is unfaithful to what it models, because a real in-place upgrade does not re-roll the codec.Root cause:
tests/config/install.shdraws the codec from("LZ4" "ZSTD(1)" "ZSTD(3)")with$RANDOMon everyconfigurecall, andtests/docker_scripts/upgrade_runner.shcallsconfiguretwice over one data directory. The draws are independent, so with p=2/3 the two servers write parts under different codecs, and a part committed before the restart is no longer byte-identical when re-merged after it. The failing jobs' logs showLZ4thenZSTD(3)in one job, and the reverse in the other.install.shgains--default-compression-codec <value>, validated against that same array and failing closed on an invalid, empty or missing value; the runner passes the codec its firstconfiguredrew to the second. Per-job randomization is preserved, so all three codecs are still covered across runs. No allow-list entry and no relaxed assertion, so every other cause of this message is still reported.This PR's own
Upgrade checkjob.log is the end-to-end check: its twoDefault compression codec:lines must now be equal.Allow-listing the message would be cheaper, but would also hide a genuine non-deterministic-merge regression and the statistics-format sub-case; happy to switch if you prefer that. No automated test is added: both files are CI job scripts, exercised only by the jobs that run them.
CI provenance:
No related open issue found.
Per-file measurement: what a codec change actually moves in a part
Three tables, identical except
SETTINGS default_compression_codec; six single-row inserts each, thenOPTIMIZE FINAL.t_lz4bis the control.hash_of_uncompressed_filesuncompressed_hash_of_compressed_filest_lz4a1a56241dde1c3b70...99aa37af378aa297...t_lz4b1a56241dde1c3b70...99aa37af378aa297...t_zstd9c16a6e6a7c7ada2...efa362b63cf5c3a3...md5sumof every file in thet_lz4aandt_zstdCompact parts:data.bindata.cmrk4uncompressed_hash_of_compressed_filesstatistics.packedhash_of_uncompressed_filescount.txt,serialization.jsonhash_of_uncompressed_filesprimary.cidxprimary_key_compression_codec, not randomizedcolumns.txt,columns_substreams.txt,metadata_version.txtWith
auto_statistics_types = ''the uncompressed-files aggregate stops diverging while the other still does, sostatistics.packedis its sole carrier. It is registered with onlyfile_size/file_hashbyserializeStatisticsPacked, whereserializeStatisticsWidealso setsis_compressed/uncompressed_hash; aligning them would not fix this failure, since the marks half survives.For a Wide part both aggregates move once a column's data spans more than one compressed block; below that every mark offset is 0 and only the statistics aggregate moves.
Workflow [PR]
Sync PR [sync-upstream/pr/121249]
Version info
26.10.1.801-master(included in26.10and later)