Repository navigation
Skip views in TRUNCATE ALL TABLES - #100943
Conversation
`TRUNCATE ALL TABLES FROM <database>` failed with "Truncate is not supported by storage View" when the database contained views. Add `supportsTruncate` virtual method to `IStorage` (default true), override it to false in `StorageView`, and delegate in `StorageProxy`. Both TRUNCATE ALL TABLES code paths (with and without LIKE pattern) now skip storages that don't support truncation. Closes #78165 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [2f70643] Summary: ✅ AI ReviewSummaryThis PR fixes Missing context
ClickHouse Rules
Final VerdictStatus: ✅ Approve |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…runcate` `StorageDictionary` did not override `supportsTruncate`, so it inherited `true` from `IStorage`. This meant `TRUNCATE ALL TABLES` would still attempt to truncate dictionaries and fail with "Cannot TRUNCATE dictionary". Override `supportsTruncate` to return false in `StorageDictionary`, and add a dictionary to the regression test. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
The test |
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
…ized-value
The `_fmt_str` member (std::string_view) was not default-initialized,
so constructors that don't explicitly set it (the default constructor
and the 3-parameter constructor) left it uninitialized. When such a
message was later logged through `TextLog`, `TextLogElement::appendToBlock`
read the garbage `string_view`, triggering a MemorySanitizer error.
Add a default member initializer `{}` so every constructor path starts
with an empty `string_view`.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100943&sha=03543a965cfbdbf1e13fc3b9ff285fd0cf526fff&name_0=PR&name_1=Stress%20test%20%28arm_msan%29
PR: #100943
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…bles-skip-views # Conflicts: # src/Storages/StorageDictionary.h
|
@alexey-milovidov — apologies for the late reply on this thread. The BuzzHouse finding from the 2026-04-25 The finding: STID Root cause: Unrelated to this PR. It's a rare chronic trunk bug in CIDB cross-PR over 30 days: 1 hit (this PR). Over 76 days the BuzzHouse fuzzer has caught it twice — also on PR #96130 in 2026-02 ( Fix: #103537 — uses an This is distinct from PR #100992 (tuanpach), which targets the separate On the parallel concern from the bot review about |
…atedMergeTree startup `StorageReplicatedMergeTree::checkPartsImpl` builds a covering set of empty unexpected parts (`set_of_empty_unexpected_parts`) by adding every empty unexpected part whose `uncovered` flag is `true`. The `uncovered` flag is set in `MergeTreeData::loadDataParts` to `true` when no other unexpected part's `MergeTreePartInfo` *contains* the current one. Two empty unexpected parts on disk can have intersecting block ranges without one fully containing the other (for example, `all_0_5_2` and `all_2_11_3`). Both parts pass the `uncovered = true` check, but `ActiveDataPartSet::add` calls `addImpl`, which throws `LOGICAL_ERROR` with the "Part X intersects previous part Y" message when the second part is added. The exception is thrown on the `BackgroundSchedulePool` thread running `ReplicatedMergeTreeAttachThread::runImpl`, aborting startup of the table. Replace `add` with `tryAdd` and log a warning when the conflicting empty marker is skipped. The set is only consulted later as a heuristic — when an unexpected part is matched against `getContainingPart` to decide whether it looks like a leftover of a dropped part — so keeping just one of two intersecting empty markers is sufficient. Any unexpected part that would have been covered by the skipped marker simply falls through to the regular handling path that detaches it as `ignored` further down in the same loop. Add a small `gtest_active_data_part_set` unit test that documents the contract: `add` throws on intersection without containment while `tryAdd` returns `HasIntersectingPart` without throwing. Reproduction comes from the BuzzHouse fuzzer (STID `2352-49be`): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100943&sha=3308ce056bdfd5672c3c300ccae03968beac9846&name_0=PR&name_1=BuzzHouse%20%28arm_asan_ubsan%29 Original PR with the BuzzHouse finding: #100943
LLVM Coverage Report
Changed lines: 85.19% (23/27) · Uncovered code |
|
Hi — this PR may need backporting to Affected code: Why: User-visible bug fix that restores documented If this should be backported, consider adding |
…ized-value
The `_fmt_str` member (std::string_view) was not default-initialized,
so constructors that don't explicitly set it (the default constructor
and the 3-parameter constructor) left it uninitialized. When such a
message was later logged through `TextLog`, `TextLogElement::appendToBlock`
read the garbage `string_view`, triggering a MemorySanitizer error.
Add a default member initializer `{}` so every constructor path starts
with an empty `string_view`.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100943&sha=03543a965cfbdbf1e13fc3b9ff285fd0cf526fff&name_0=PR&name_1=Stress%20test%20%28arm_msan%29
PR: ClickHouse#100943
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The cherry-pick of #121134 only overrides `supportsTruncate` in `StorageAlias`, but on 26.3 nothing consults that method: the virtual was added to `IStorage` and wired into both database-wide `TRUNCATE` paths of `InterpreterDropQuery` by #100943 ("Skip views in `TRUNCATE ALL TABLES`"), which was never backported. Without it the `Alias` override is dead code and the new test fails. Bring in the source part of #100943 verbatim (`IStorage`, `StorageView`, `StorageDictionary`, `StorageProxy`, `InterpreterDropQuery`) together with its regression test, renumbered from 04070 to 05232 because the 04070 prefix is already taken on this branch. Related: #100943 Related: #121134 Co-Authored-By: Claude Fable 5.1 <[email protected]>
TRUNCATE ALL TABLES FROM <db> collects every table whose
IStorage::supportsTruncate() is true (InterpreterDropQuery.cpp:716),
truncates them in a thread pool, and rethrows the first error only after
every job has run (:795). The predicate defaults to true
(IStorage.h:545) while the IStorage::truncate() it falls back to throws
NOT_IMPLEMENTED (IStorage.cpp:214-221). So an engine that stores nothing
at all, and therefore never implemented truncate(), is nevertheless
collected and then throws - failing the statement for the whole database
after the truncatable tables in it were already emptied. The caller gets
a statement that is both rejected and partially applied, with no way to
tell how far it got.
A false answer from that predicate means "omit this table silently",
which is sound exactly when the storage has no data of its own. That is
why StorageView, StorageDictionary and the URL scheme dispatcher already
return false. Add the same one-line override to the engines that
provably store nothing: Merge (a read-time union over other tables),
Null (discards every insert), GenerateRandom, FuzzQuery and FuzzJSON
(synthesise rows on read), Executable and ExecutablePool (run a user
script on read), and QueryRunner (a write-only sink with no read path at
all). Truncating any of them is a no-op by construction, so skipping
them removes nothing.
URL is the one member justified by an existing in-tree decision rather
than by storing nothing: StorageURL.cpp already gives
StorageURLSchemeDispatch supportsTruncate() == false plus a rethrowing
truncate(), precisely so that a table declared as URL is never
truncated. Plain StorageURL was left out, so URL('file://...') is
skipped today while URL('http://...') fails the statement. This
completes that decision rather than taking a new one.
The IStorage default deliberately stays true, so an engine nobody marked
keeps exactly today's visible error and can never be skipped silently.
Engines that hold rows of their own, or are backed by a system that does
- Buffer, MySQL, PostgreSQL, MongoDB, SQLite, BigQuery, ODBC, JDBC,
Kafka and the other streaming storages - are deliberately left failing:
marking them would report success over surviving data. StorageXDBC
(ODBC/JDBC) derives from IStorageURLBase, not from StorageURL, so the
override here does not reach it. An explicit TRUNCATE TABLE never
consults the predicate (executeToTableImpl), so it is unchanged for
every engine.
Follows ClickHouse#100943, which did the same for views and dictionaries.
Co-Authored-By: Claude Opus 5 <[email protected]>
TRUNCATE ALL TABLES FROM <database>failed with "Truncate is not supported by storage View" when the database contained views.Add
supportsTruncatevirtual method toIStorage(default true), override it to false inStorageView, and delegate inStorageProxy. Both TRUNCATE ALL TABLES code paths (with and without LIKE pattern) now skip storages that don't support truncation.Closes #78165
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
TRUNCATE ALL TABLESno longer fails when the database contains views.Documentation entry for user-facing changes
Version info
26.5.1.212