Repository navigation
Fix Min-Max index file-order hint after part_minmax_index_columns downgrade - #111511
Conversation
…ngrade
getProbablyWrittenFiles threw a LOGICAL_ERROR ("Part level Min-Max index was
constructed from unexpected columns set") during a background merge when a part's
in-memory min-max hyperrectangle was larger than the current part_minmax_index_columns
setting prescribes. This is a legitimate transitional state: a part written (or cached
in memory) under with_block_number_offset keeps its _block_number/_block_offset entries
after the setting is lowered to partition_key_only, until it is dropped by a reload or
rebuilt by a merge. store() already handles this by writing only
min(current column count, hyperrectangle size) files; the file-order hint now mirrors
that same clamp instead of demanding an exact size match and aborting.
The result of getProbablyWrittenFiles is only a best-effort file-ordering hint for the
packed-part archive layout, so it must not abort on a valid transitional index.
Reproduced deterministically (new stateless test): insert compact parts under
with_block_number_offset, cache their min-max index, ALTER the setting down to
partition_key_only, then merge.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-6:20260723-010500 |
Internal second-model review — adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings across 1 full pass + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-author-slot-6:20260723-010500 |
|
cc @CurtizJ @CheSema — could you review this? It fixes a |
|
Workflow [PR], commit [285a27f] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 8/8 (100.00%) · Uncovered code |
CI finish ledger - 285a27fCI fully finished: 161 checks green, 0 failures. No red lines to own; the PR is CI-clean and ready for review. Session id: cron:our-pr-ci-monitor:20260723-213000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERROR("Part level Min-Max index was constructed from unexpected columns set") that could abort a background merge in debug/sanitizer builds afterpart_minmax_index_columnswas lowered (for example fromwith_block_number_offsetback topartition_key_only).Description
Found by the Stress test (arm_asan_ubsan) on PR #42701 (unrelated to that PR):
report https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=42701&sha=3f6eab14d9d3cac7d7f3add30f551a43820e4ddb&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%29 , STID 5721-5ce7.
MinMaxIndex::getProbablyWrittenFiles(reached fromgetPreferredFileOrderduring merge/mutation finalize) accepted the in-memory hyperrectangle only when its size exactly matched one of two column sets derived from the currentpart_minmax_index_columnssetting, and threw aLOGICAL_ERRORotherwise.The min-max index has upgrade semantics: a part written under a wider
part_minmax_index_columnskeeps its extra hyperrectangle entries (partition key plus_block_number/_block_offset) until a merge or mutation re-materializes it. After the setting is lowered, such a part's index is legitimately larger than the current setting prescribes, so the exact-size check failed and the merge aborted.getProbablyWrittenFilesonly produces a best-effort file-ordering hint for the packed-part archive layout, andstore()already writes just the leadingmin(current column count, hyperrectangle size)min-max files. The hint now mirrors that same clamp instead of requiring an exact match, so a valid transitional index no longer aborts the merge. On-disk output is unchanged.Reproduced deterministically (see the new stateless test
04626_minmax_block_number_downgrade_merge): insert parts underpart_minmax_index_columns='with_block_number_offset', load their min-max index into memory,ALTERthe setting down topartition_key_only, then merge. The test fails on the current server (merge aborts) and passes with this change. No related open issue was found.