Repository navigation
Use llvm-project 22.1.1 - #98882
Use llvm-project 22.1.1#98882
llvm-project 22.1.1#98882Conversation
Update the `contrib/llvm-project` submodule from LLVM 21 (release/21.x) to LLVM 22 (release/22.x). All 11 ClickHouse-specific patches were cherry-picked onto the new `ClickHouse/release-22.x` branch in the fork; the e2k `config.guess` patch was already upstream and skipped. Changes in the main repo: - Bump `LLVM_VERSION` to `22.1.1bundled` - Add `_LIBCPP_ASSERTION_SEMANTIC_DEFAULT` to `__config_site` (new requirement in LLVM 22 hardening framework) - Remove `common_constants.cpp` from `libllvmlibc` sources (moved to header-only in LLVM 22) Assisted-by: Claude Opus 4.6 via GitHub Copilot
|
Workflow [PR], commit [929733e] Summary: ✅ AI ReviewSummaryThis PR upgrades bundled Missing context
ClickHouse Rules
Final Verdict
|
LLVM 22 libc++ removed transitive includes that older versions provided. Code relying on `<map>` being transitively included now needs an explicit include. Assisted-by: Claude Opus 4.6 via GitHub Copilot
- `StorageFile.cpp`: suppress `[[nodiscard]]` warning on `fs::canonical` called only for its side-effect (throwing if file does not exist) - `StorageMergeTree.cpp`: suppress thread-safety analysis on `movePartitionToTable` where `std::lock` + `std::adopt_lock` pattern for two mutexes is correct but opaque to the analyzer Assisted-by: Claude Opus 4.6 via GitHub Copilot
LLVM 22 libc++ removed implicit `operator==` synthesis for types that only define `operator!=`. The `TEnumIterator` class in thrift 0.16.0 only had `operator!=`, causing build failures with the new `__tree::__insert_range_unique` that requires `operator==`. Upstream fixed this in apache/thrift PR #2633 (THRIFT-5603), included in v0.22.0. Cherry-picked the ClickHouse locale patch (`std::locale::classic()` instead of `std::locale("C")`) on top. Assisted-by: Claude Opus 4.6 via GitHub Copilot
- `Intrinsic::getDeclaration` renamed to `Intrinsic::getOrInsertDeclaration` in LLVM 22 (abs.cpp, bitCount.cpp) - `createTargetMachine` first argument changed from `StringRef` to `const Triple&` — construct `llvm::Triple` explicitly (CHJIT.cpp) - `std::__gcd` internal removed from libc++ — use `std::gcd` from `<numeric>` (AggregateFunctionKolmogorovSmirnovTest.cpp) - Added `(void)` casts for new `[[nodiscard]]` on `std::stod`, `std::filesystem::is_directory`, and `future.get()` (KQLGeneralFunctions.cpp, LocalServer.cpp, ZooKeeperRemoveByList.cpp, EphemeralLockInZooKeeper.cpp) Assisted-by: Claude Opus 4.6 via GitHub Copilot
Construct DataTypeQBit on the stack instead of using std::make_shared, avoiding the unused-result warning on the discarded shared_ptr.
The LLVM 22 libc++ upgrade changed std::unordered_map behavior such that a copy no longer preserves iteration order. This exposed two latent bugs in the text index prewhere machinery: 1. `IndexReadTasks` (`std::unordered_map`) is copied into `MergeTreeReadPoolBase` and then iterated independently in `getPrewhereActions` / `getReadTaskColumns`. When the copy has a different iteration order, prewhere readers and actions get paired by index incorrectly, producing either LOGICAL_ERROR (column count mismatch) or ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER (String in a filter position). Fixed by switching to `std::map` for deterministic order. 2. The `MergeTreeRangeReader` constructor executed prewhere step actions on `result_sample_block` for `None`-type steps (text index read steps), but `executePrewhereActionsAndFilterColumns` skips them at runtime. This caused the sample block column order to diverge from the actual data, leading to wrong query results when two text indexes are present. Fixed by skipping action execution on the sample block for `None`-type steps, matching the runtime behavior.
LLVM Coverage Report
Changed lines: 73.81% (62/84) | lost baseline coverage: 17 line(s) · Uncovered code |
|
Backport labels have been automatically added based on https://github.com/ClickHouse/clickhouse-core-incidents/issues/1792 Labels added:
These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels. |
Manual backport of 1c1c031 ("Fix text index prewhere mismatch with multiple indexes") from #98882. With `query_plan_direct_read_from_text_index` and `use_skip_indexes_on_data_read`, the text index read is a `None`-type prewhere step. `MergeTreeRangeReader` executed that step's actions on the sample block in its constructor, while `executePrewhereActionsAndFilterColumns` skips `None`-type steps at runtime. When a row-level filter (e.g. a `ROW POLICY`) reads a `String` column before the `None` step, the sample-block column order diverged from the actual data, so the raw `String` column landed in a filter position and the query raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` ("Illegal type String of column for filter"). The fix skips executing step actions on the sample block for `None`-type steps, to match the runtime behavior. It also switches `IndexReadTasks` / `IndexReadColumns` to `std::map` for deterministic iteration order (the multiple-text-index variant of the same class of mismatch). Adds `04332_text_index_direct_read_row_policy` reproducing the single-index `ROW POLICY` case. Verified against public builds bracketing the fix: it raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` on 26.4.1.689 (commit c1225a6, before PR #98882) and returns 1000 on 26.4.1.691 (commit 4d79f6e, the PR #98882 merge). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Manual backport of 1c1c031 ("Fix text index prewhere mismatch with multiple indexes") from ClickHouse#98882. With `query_plan_direct_read_from_text_index` and `use_skip_indexes_on_data_read`, the text index read is a `None`-type prewhere step. `MergeTreeRangeReader` executed that step's actions on the sample block in its constructor, while `executePrewhereActionsAndFilterColumns` skips `None`-type steps at runtime. When a row-level filter (e.g. a `ROW POLICY`) reads a `String` column before the `None` step, the sample-block column order diverged from the actual data, so the raw `String` column landed in a filter position and the query raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` ("Illegal type String of column for filter"). The fix skips executing step actions on the sample block for `None`-type steps, to match the runtime behavior. It also switches `IndexReadTasks` / `IndexReadColumns` to `std::map` for deterministic iteration order (the multiple-text-index variant of the same class of mismatch). Adds `04332_text_index_direct_read_row_policy` reproducing the single-index `ROW POLICY` case. Verified against public builds bracketing the fix: it raised `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` on 26.4.1.689 (commit c1225a6, before PR ClickHouse#98882) and returns 1000 on 26.4.1.691 (commit 4d79f6e, the PR ClickHouse#98882 merge). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
text index prewhere fix) STOR: with query_plan_direct_read_from_text_index and use_skip_indexes_on_data_read, each text index read is a None-type PREWHERE step. IndexReadTasks/IndexReadColumns were std::unordered_map: the map is copied into the read pool and iterated again in getPrewhereActions and getReadTaskColumns, and a copy need not iterate in the same order, so the PREWHERE readers and the PREWHERE actions of the index steps could be paired differently. In addition MergeTreeRangeReader executed the actions of None-type steps on its sample block although executePrewhereActionsAndFilterColumns skips them at run time, so the sample block and the data diverged. Upstream switches both maps to std::map and skips None-type steps on the sample block (26.3 backport ClickHouse#107758 of 1c1c031 from ClickHouse#98882; 26.4+ have it through ClickHouse#98882). Effect in the fork: with three partially materialized text indexes in one query (04411, third section) the backport of ClickHouse#108607 (a6ab685) ran equals(a, 'alpha') on a column that was not the String column a and failed with TOO_DEEP_RECURSION (KD-UP-TEXTINDEX-DIRECTREAD-3IDX); with a row policy on a String column the upstream test 04332 fails with ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER. Upstream patch unchanged (applies cleanly), with its test 04332_text_index_direct_read_row_policy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Backporting to 26.3 for #122836 |
Resolves the one conflict in the automated cherry-pick, `contrib/thrift`. 26.3 already carries Apache Thrift v0.24.0, backported as #111278, while #98882 was the earlier step that moved master from v0.16.0 to v0.22.0. Taking the cherry-picked side would downgrade the submodule, so ours is kept: 26.3 and master both stay on 13d30d6a6cdf (v0.24.0). Everything else merged cleanly. `MergeTreeRangeReader.cpp` and `MergeTreeReadTask.h` come out unchanged because the text-index prewhere fix that rides along with this PR is already on 26.3, so git recognised it as applied rather than dropping it. Original pull-request: #98882 Cherry-pick pull-request: #122872 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Backport #98882 to 26.3: Use `llvm-project` 22.1.1
Linked issues
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Use
llvm-project22.1.1Documentation entry for user-facing changes
Version info
26.4.1.691-master(included in26.4and later)26.3.37.2