Repository navigation
Conversation
A table created with `SETTINGS disk = disk(...)` (inline custom-disk function) could not be altered: every `ALTER` raised `Bad get: has CustomType, requested String. (BAD_GET)`. This happened even on alters that do not touch the `disk` setting (e.g. `ADD COLUMN`, `MODIFY COLUMN`, or `MODIFY SETTING` for any other setting), because the ALTER pipeline re-applies the table's `settings_changes` AST through the validation pipeline and the parser stores `disk = disk(...)` as a `CustomType` `Field` wrapping the function AST, which trips `SettingFieldString::operator=` in `BaseSettings::applyChanges`. The CREATE path already handled this in `MergeTreeSettingsImpl::loadFromQuery`: it intercepts the `CustomType` field, calls `DiskFromAST::createCustomDisk` to register the inline disk, and replaces the value with the resulting disk name string before calling `applyChanges`. The ALTER path skipped this conversion in several places. Extract that conversion into reusable helpers in `DiskFromAST`: - `convertCustomDiskField(Field & value, context, attach)` — the per- field conversion (extracted from `loadFromQuery` / `DatabaseMetadataDiskSettingsImpl::loadFromQuery` which already duplicated this logic). - `convertCustomDiskSettings(SettingsChanges & changes, context, attach)` — walks a settings-changes vector and converts any change named `disk`. Used by every code path that re-applies a table's `settings_changes` AST. Apply the conversion in three previously-affected ALTER call sites in `MergeTreeData`: - `changeSettings` (the actual ALTER apply path, called by `StorageMergeTree::alter` and `StorageReplicatedMergeTree::alter`). - `checkAlterIsPossible`'s settings-validation block, which calls `MergeTreeSettings::checkCanSet`, `safeGet<String>`, and `applyChanges` on each new setting. - `checkColumnFilenamesForCollision(metadata, ...)`, which is called from `checkAlterIsPossible` and re-applies the changes onto a fresh default settings instance to enumerate per-column file names. Also refactor the existing CREATE-path callers (`MergeTreeSettingsImpl::loadFromQuery` and `DatabaseMetadataDiskSettingsImpl::loadFromQuery`) to use the new helpers — pure de-duplication, no behaviour change. Adds regression test `04145_alter_with_inline_disk_setting.sql` covering all three throw sites: `ADD COLUMN`, `MODIFY COLUMN`, and a non-`disk` `MODIFY SETTING` (which still re-applies the inline `disk` through `changeSettings`). Closes ClickHouse#63019 Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Pre-PR validation gate (per our internal worker procedure) Session: `cron:clickhouse-ci-task-worker:20260501-034500` a) Deterministic repro? Yes. The exact two queries from #63019: ```sql ALTER TABLE test_mt ADD COLUMN c Int64 AFTER b; reproduce 100% of the time on master HEAD before the fix. b) Root cause explained? The parser produces a `Field` with type `CustomType` (a `FieldFromASTImpl` wrapping the `disk(...)` AST). `MergeTreeSettingsImpl::loadFromQuery` (CREATE path) intercepts this and converts it to a registered disk-name `String` via `DiskFromAST::createCustomDisk` before calling `applyChanges`. The ALTER pipeline did NOT do this conversion in any of: `MergeTreeData::changeSettings`, `MergeTreeData::checkAlterIsPossible`, `MergeTreeData::checkColumnFilenamesForCollision`. So when these called `safeGet` / `applyChanges` / `MergeTreeSettings::checkCanSet` on the `CustomType` `Field`, they threw `BAD_GET`. Stack trace from the failing run: ``` c) Fix matches root cause? Yes — the fix mirrors the CREATE-path conversion in all three ALTER call sites via a shared `DiskFromAST::convertCustomDiskSettings(SettingsChanges &, ContextPtr, bool)` helper. Targeted (only the `disk` setting is special-cased), no `try/catch`, no skipping the validation. d) Test intent preserved? / New tests added? No existing assertion is weakened. New test `04145_alter_with_inline_disk_setting.sql` covers all three throw sites: `ADD COLUMN` (hits `checkColumnFilenamesForCollision`), `MODIFY COLUMN` (hits the `checkAlterIsPossible` validation block), and a non-`disk` `MODIFY SETTING` (hits `changeSettings` — the actual apply path). e) Both directions demonstrated? Yes. Without the patch the test fails on every iteration with `BAD_GET`; with the patch it passes 10/10 with full settings randomization on a debug build. f) Fix is general, not a narrow patch? I checked every `applyChanges` / `safeGet` / `checkCanSet` site that consumes a metadata `settings_changes` AST in MergeTree code (`MergeTreeData.cpp` lines 4691, 4876, 8952; `MergeTreeSettings.cpp` line 2287; the validation block in `checkAlterIsPossible`). Each one that hit the bug is now protected. The same conversion was already present in `DatabaseMetadataDiskSettings.cpp` — I refactored it to use the shared helper for consistency. I also asked why the bad state arrives here: the `CustomType` representation is intentional (the parser preserves the `disk(...)` AST so it can be re-serialised in the table's CREATE statement), so the fix correctly converts at every consumer rather than trying to "fix the source". |
|
cc @kssenii (issue author + comp-object-storage-disks owner) and @alesapin (comp-mergetree manager) — could you review? The fix mirrors the CREATE-path Also @PedroTadim — thanks for the nudge, this should fix the |
|
Workflow [PR], commit [5ea3364] Summary: ✅
AI ReviewSummaryThis PR fixes the main Findings❌ Blockers
Final VerdictChanges requested. |
|
@groeneai can you add the |
…ouse#63019 Per @PedroTadim's review request on PR ClickHouse#103818, extend 04145_alter_with_inline_disk_setting with explicit coverage of `ALTER TABLE ... MODIFY SETTING disk = disk(...)` — i.e., changing the `disk` setting itself to another inline `disk(...)` function, which is the exact form @PedroTadim originally hit on issue ClickHouse#63019. Two cases: 1. Idempotent: re-applying the SAME inline `disk(...)` value via `MODIFY SETTING`. This still flows through `convertCustomDiskSettings` and `change.value.safeGet<String>()` in `MergeTreeData::changeSettings`, which is exactly the call site that threw `BAD_GET` (code 170) before the fix. With the fix the storage policy is the same → no migration → silent success → table data still readable. 2. Cache wrap: `MODIFY SETTING disk = disk(type = cache, ...)` wrapping the existing inline disk by name. Before the fix this threw `BAD_GET` in `checkAlterIsPossible` at the `safeGet<String>` call. After the fix the `CustomType` conversion succeeds and the request is correctly rejected by the storage-policy migration guard with `BAD_ARGUMENTS` (code 36) — changing the `disk` to a different storage policy is not permitted because the new policy must include all old disks. Asserted via `{ serverError BAD_ARGUMENTS }`. The crucial property is that the error code is 36 (domain-level validation) and not 170 (`Field` type crash). Verified locally: * 20/20 passes on the fix branch with the test runner's full settings randomization. * Manually reproduced the pre-fix path by reverting just the `convertCustomDiskSettings` call in `MergeTreeData::changeSettings`, rebuilding, and confirming the same-disk MODIFY SETTING then throws `Code: 170. BAD_GET`. Closes ClickHouse#63019 (test coverage).
|
@PedroTadim — done in 0b44e16. Added two
Verified locally:
Session: cron:clickhouse-ci-task-worker:20260505-104500 |
…adim) After @PedroTadim asked for additional `SELECT` queries between the `INSERT`s and `ALTER`s in `tests/queries/0_stateless/04145_alter_with_inline_disk_setting.sql`, add `SELECT a, ... ORDER BY a` queries after every `INSERT` and after every `ALTER` that the test exercises. The new reads: * verify the inline-disk-backed table is fully functional after each metadata transition, not just that the `ALTER` itself didn't throw `BAD_GET`, * exercise the actual disk read path (the previous test only ran `count()` / `sum()` aggregates, which can be answered from the MergeTree primary index without touching the data files), * assert no data is lost or corrupted after the rejected `MODIFY SETTING disk = disk(type = cache, ...)` `ALTER` rolls back. Verified locally: 20/20 passes with `--test-runs=20` under full settings randomization on debug build. PR: ClickHouse#103818 Issue: ClickHouse#63019 Review request: ClickHouse#103818 (comment)
|
@PedroTadim Done in 8da1ad2 — added The new reads:
Verified locally: 20/20 passes with |
|
@groeneai the test is failing, can you check? |
The flaky check iterations of `04145_alter_with_inline_disk_setting` failed intermittently with: filesystem error: in create_directory: No such file or directory ["...run_r0/disks/63019_modify_disk/store"] on `CREATE TABLE t_63019_modify_disk`. The failure was introduced together with the table itself in commit 0b44e16 (52 fails / 56 runs across the last two PR commits, vs 0 fails on the original 21d7eca fix commit). Root cause: the metadata storage's default path is `<context.getPath()>/disks/<disk_name>/` (see `MetadataStorageFactory.cpp`). The `t_63019_modify_disk` table's user-provided object-storage `path` was `./disks/63019_modify_disk/`, whose last component matched its disk `name` (`63019_modify_disk`). On CI builds where the server's working directory coincides with its `--path` data directory (the `run_r0` layout used by `ci/jobs/scripts/clickhouse_proc.py`), the user path and the metadata default path resolved to the same on-disk directory, leaving the metadata side's later `DiskLocal::createDirectory("store")` (a non-recursive `fs::create_directory`) racing the object-storage side's directory lifecycle. Fix: make the user-provided `path`'s last component differ from the disk `name` so the two storages live in distinct directories on every layout. The path style now mirrors `02963_test_flexible_disk_configuration.sql`, which uses similar single-level paths and has no `create_directory` failures in 60-day history. Test logic (CREATE / ADD COLUMN / MODIFY COLUMN / MODIFY SETTING / INSERT / SELECT / MODIFY SETTING disk = disk(...) idempotent / MODIFY SETTING disk = disk(type = cache, ...) rejection) is unchanged; only the on-disk paths are renamed. The fix's `convertCustomDiskSettings` code path is still exercised by the two `MODIFY SETTING disk = disk(...)` statements. Verified locally: 20/20 passes on a fresh server with full settings randomization. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103818&sha=8da1ad26a953030e66bd49117d5d5aef537c81ae&name_0=PR PR: ClickHouse#103818 Issue: ClickHouse#63019
|
@PedroTadim — diagnosed and fixed in Root cause: the metadata-storage default path is Confirmed via CIDB: 0 fails on Fix: make every user-provided Verification: 20/20 passes on a fresh local server with full settings randomization. Awaiting CI on the new commit. |
|
@kssenii can you review the changes? |
Resolve conflicts in: - src/Databases/DatabaseMetadataDiskSettings.cpp - src/Storages/MergeTree/MergeTreeSettings.cpp Master inlined the disk-from-AST conversion (via the new IMPLEMENT_SETTINGS_TRAITS_CUSTOM_IMPL macro refactor and Algunenano's settings vtable removal). Our branch refactored that same logic into reusable helpers in DiskFromAST (convertCustomDiskField, convertCustomDiskSettings). Resolution: keep our helper-call form and pass the master-renamed parameter is_loading_from_existing_metadata. No semantic change to the fix for issue ClickHouse#63019.
…line disk Per @clickhouse-gh[bot]'s review on ClickHouse#103818, two `BAD_GET` call sites remained unhandled after the original three-site fix: 1. `MergeTreeData::checkAlterIsPossible` — the `UNIQUE KEY` storage-policy validation guard (lines 4360-4392) reads `new_metadata.settings_changes->as<const ASTSetQuery &>().changes` directly and calls `safeGet<String>` on the `disk`/`storage_policy` value before any of the other three conversion sites are reached. A `UNIQUE KEY` table created with inline `SETTINGS disk = disk(...)` would throw `Bad get: has CustomType, requested String` here on any later `ALTER`. 2. `AlterCommand::apply` — the `MODIFY_SETTING` branch now computes effective `MergeTreeSettings` from `settings_from_storage` to derive `add_minmax_index_for_*` flags (a code path introduced by the master rebase, after `IMPLEMENT_SETTINGS_TRAITS_CUSTOM_IMPL`). It iterates the existing `settings_from_storage` and calls `applyChange` on every built-in MergeTree setting, including a still-`CustomType` `disk` value, also tripping `BAD_GET`. Both fixes follow the same pattern as the original three call sites: take a non-const copy of the changes vector and call `DiskFromAST::convertCustomDiskSettings` on it before iterating. Regression test additions in `tests/queries/0_stateless/04145_alter_with_inline_disk_setting.sql`: - A `UNIQUE KEY` table created with inline `SETTINGS disk = disk(...)` exercises ADD COLUMN, MODIFY SETTING, and INSERT after ALTERs. The table uses a local custom disk (UNIQUE KEY rejects object-storage disks) under `/var/lib/clickhouse/disks/`, the `custom_local_disks_base_directory` configured by `tests/config/config.d/custom_disks_base_path.xml`. - The non-`UNIQUE KEY` `MODIFY SETTING merge_with_ttl_timeout` case was already in the file from a previous commit; it now also covers the new `AlterCommand::apply` call site. Verified locally: 30/30 passes via `clickhouse-test --test-runs 30` with full settings randomization. With either fix individually reverted the test fails deterministically at the corresponding ALTER.
|
This was fixed by #105146. Let's update the branch. |
|
@groeneai merge one more time with master, so we can merge |
…merge-master-20260602
|
@PedroTadim merged current master in 14cdb33 (clean, no conflicts). CI re-running. |
|
📊 Cloud Performance Report ✅ AI verdict: Both diffs (private and public PR 103818) are confined to custom-disk DDL handling: inline disk(...) registration, ALTER/CREATE validation rollback, FileCacheFactory and storage-policy cleanup, plus test-only fail points. None of that runs in the read path that ClickBench Q4 or Q15 execute, so a ~19-20% speedup on those two SELECTs cannot plausibly come from this change. Two unrelated queries showing a near-identical delta at the same magnitude points to run-to-run/environment variance rather than a real PR effect, so both flagged improvements are downgraded to not-sure. clickbenchFlagged queries (2 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Issue: clickhouse-gh[bot] review on PR ClickHouse#103818 flagged that `DiskFromAST::convertCustomDiskSettings` is not just a normalisation step. For an inline `disk(...)` value it calls `createCustomDisk`, which mutates the global `DiskSelector` via `Context::getOrCreateDisk`. Several validation paths (`AlterCommand::apply` on a metadata copy, `MergeTreeData::checkAlterIsPossible` (both the UNIQUE KEY guard and the storage-policy migration check), `MergeTreeData::checkColumnFilenamesForCollision`) run before the ALTER is committed and can throw after the disk has been registered. The test's rejected `MODIFY SETTING disk = disk(name = '63019_modify_disk_cache', ...)` reaches the validation path, registers `63019_modify_disk_cache`, and is then rejected by the storage-policy migration guard with `BAD_ARGUMENTS`. Without rollback, the inline disk's name remained reserved in the global selector until restart and any later `CREATE TABLE` that reused the same name with different settings failed as if another table already owned it. Fix: introduce `DiskFromAST::CustomDiskRegistrationScope`, a RAII guard that records names registered while it is alive and removes them on destruction unless `commit` was called. Propagate an optional `scope` parameter through `convertCustomDiskSettings` / `convertCustomDiskField` / `createCustomDisk` / `getOrCreateCustomDisk`. Inside `getOrCreateCustomDisk` the new registration is detected via the `DiskCreator` callback and recorded on the scope. Wrap the four validation call sites with their own scope (no commit, so the destructor always rolls back) and the actual apply site (`MergeTreeData::changeSettings`) with a scope that is committed only after `setInMemoryMetadata` (the metadata transition is now durable). A successful validation pass rolls back its disk; the subsequent apply pass re-registers it via the same idempotent `getOrCreateDisk` path, so behaviour is unchanged for accepted ALTERs. Add `DiskSelector::removeFromDiskMap` and `StoragePolicySelector::remove` plus a single public entry point `Context::removeCustomDiskAndStoragePolicy` that takes the existing `storage_policies_mutex` and removes both the disk and the auto-created `__<disk_name>` single-disk storage policy. The removal is gated by `disk->isCustomDisk()` to never delete a config-defined disk. Test: extend `04145_alter_with_inline_disk_setting.sql` with a rollback scenario that creates a base table on an inline custom disk, runs a rejected `MODIFY SETTING disk = disk(name = '63019_rollback_v1', ...)` ALTER (rejected by the storage-policy migration guard), then creates a fresh table reusing `63019_rollback_v1` with different settings. Without the rollback the second `CREATE` fails with "already configured as a custom disk in another table"; with the rollback it succeeds. Closes: ClickHouse#63019 Related: ClickHouse#103818 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@PedroTadim addressed the bot's validation side-effect concern in 9824d97. Added Backing API (used only by the new rollback path, gated on
Pre-PR validation gate
Session id: |
The settings-only and mixed settings/comment ALTER branches called changeSettings against a caller-owned CustomDiskRegistrationScope before the metadata write, but outside the catch that reverts the live state. changeSettings mutates the live storage_settings and in-memory metadata (setInMemoryMetadata) and then runs post-transition work (startBackgroundMovesIfNeeded / startStatisticsCache), both of which create and schedule pool tasks and can throw. A throw there propagated out of changeSettings before the caller entered its try, so the catch-revert never ran while the scope destructor still rolled the tentative inline disk back, leaving the live settings mutated and (on the inline-disk path) resolving to a disk no longer present in DiskSelector. A later successful ALTER would then persist those stale live settings. Move changeSettings inside the same try as the metadata write in the non-replicated and replicated settings-only branches and in the replicated mixed settings/comment branch, and arm the SCOPE_EXIT revert before changeSettings in the replicated ZooKeeper loop, so a throw anywhere inside changeSettings reverts the live settings first. When changeSettings throws before mutating anything, the revert re-applies the unchanged old settings, a harmless no-op. Add the ONCE failpoint merge_tree_change_settings_fail_after_set_metadata (fires only in caller-owned mode, after setInMemoryMetadata) and regression test 04161 covering MergeTree and ReplicatedMergeTree. Closes ClickHouse#63019 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-0:20260617-063800 |
clickhouse-gh[bot] flagged three coupled issues on PR ClickHouse#103818 (issue ClickHouse#63019): CR-3 (source): doCreateOrReplaceTable creates a random replacement table via the inner doCreateTable, then runs fillTableIfNeeded and the final rename/exchange. The inner create committed the ambient CustomDiskRegistrationScope as soon as the random table's metadata was durable, but the user-visible DDL is durable only after the rename. A fill or rename failure dropped the random table while the inline custom disk stayed committed in DiskSelector / FileCacheFactory, leaving the disk name reserved with no owning table; a later CREATE reusing that name with different settings was rejected by the settings-hash check until restart. Fix: doCreateOrReplaceTable now installs the ambient scope across the temporary create + fill + rename/exchange and commits only after the rename succeeds; the inner doCreateTable is told the caller owns the scope (new disk_scope_owned_by_caller arg) so it neither installs a nested scope nor commits early. On the catch path the temporary table is dropped while the scope is uncommitted, so its destructor rolls the disk back. New regression 04162 drives the late failure with a ONCE failpoint create_or_replace_fail_after_inner_create and asserts disk-name reuse with different settings succeeds after the failed CREATE OR REPLACE (it does not without the fix). Both directions verified locally on a clang-21 debug build. CR-2: now that normal CREATE runs under the ambient scope, an observing CREATE joins the disk's active_owners (scoped) rather than the unscoped_observers refcount path. 04154 and 04155 still exercise the (real) scoped last-owner-leaves rollback and co-owner independence, but their descriptions claimed the unscoped_observers path; reframed to describe the ambient-scoped ownership they now cover and noted that the no-ambient-scope fallback (releaseUnscopedDiskObservation / commitUnscopedDiskObservation) is reached only by background metadata / lazy loading, not interactive DDL. CR-1: the failpoint stateless tests enabled server-wide failpoints (and paused background clients) but only cleaned up on the success tail; an early failure could leave a failpoint enabled or a client paused and disrupt later tests on the same server. Added EXIT traps that disable/notify the failpoints, kill background PIDs, and drop the test tables, to 04152-04157 and 04159-04162 (mirroring 04141_transaction_after_commit_no_premature_wakeup). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (commit 52757c4 — bot CR-1/CR-2/CR-3 follow-up)
Session id: cron:clickhouse-worker-slot-2:20260617-080200 |
…cated ALTER Two remaining exception-safety gaps flagged by review on PR ClickHouse#103818 (issue ClickHouse#63019). 1. CREATE OR REPLACE cleanup DROP that throws (InterpreterCreateQuery.cpp). doCreateOrReplaceTable creates a randomly-named temporary table via the inner doCreateTable (its metadata is durable, any inline custom disk is registered under the caller-owned CustomDiskRegistrationScope), then fills and renames it. If a step before the rename throws, the catch path drops the temporary table while the scope is uncommitted, so the scope destructor rolls the inline disk back. That is correct only when the cleanup DROP actually removes the temporary table. If the cleanup DROP itself throws, the catch logged and kept rethrowing while the scope was still uncommitted, so the disk was rolled out of DiskSelector / FileCacheFactory even though the temporary table's durable metadata survived and still referenced it. Now the scope is committed (disk kept) when the cleanup DROP fails, so the disk stays registered while a durable table still references it; a later DROP of the leftover table releases it through the normal path. 2. Replicated ALTER local metadata durably ahead of ZooKeeper (StorageReplicatedMergeTree.cpp). A mixed structural plus settings/comment ALTER runs the full ZooKeeper-replicated loop, which writes the modified create query to the local metadata file via DatabaseCatalog::alterTable before committing with tryMulti. If tryMulti returns a non-ZOK error or a later pre-commit step throws, the loop's SCOPE_EXIT restored only the in-memory settings/metadata, not the durable file. The live table read correctly, but the on-disk create query kept the failed setting, so a restart (or DETACH/ATTACH) reloaded it, and on the inline-disk path it referenced a disk the caller-owned scope had already rolled back. The revert now also rewrites the local metadata file back to the pre-ALTER state (before the disk scope rolls any inline disk back); the durable rollback is armed right after the local write and disarmed after a successful ZooKeeper commit. Regression tests use ONCE failpoints to drive each window deterministically: - 04163: enables create_or_replace_fail_after_inner_create plus create_or_replace_fail_cleanup_drop and asserts the inline disk is kept and the leftover temporary table resolves its disk. - 04164: enables replicated_alter_fail_after_local_metadata_before_zk, runs a mixed ADD COLUMN plus MODIFY SETTING ALTER that fails, then DETACH/ATTACH to reload from the durable file and asserts the failed setting is reverted. Closes ClickHouse#63019 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-5:20260617-092800 |
createDatabase registers any inline metadata custom disk (SETTINGS disk = disk(...)) under the ambient CustomDiskRegistrationScope. After it attaches the database and makes the metadata .sql file durable (renamed = true), the catch path removes the metadata file and detaches the database while the scope is still uncommitted, so the scope destructor rolls the inline disk back. That is correct only when the cleanup fully removes the durable metadata and detaches the database. The gap: removeFileIfExists or detachDatabase can itself throw. The catch then kept rethrowing while the scope was uncommitted, so ~CustomDiskRegistrationScope rolled the inline disk out of DiskSelector / FileCacheFactory even though the durable metadata .sql (and the still attached database) kept referencing that disk. A restart would then fail to load the .sql because the disk it names is gone. Wrap the cleanup in an inner try; on cleanup failure commit the scope (keep the disk) before rethrowing, since ownership is uncertain while durable metadata / an attached database may still reference the disk. A later DROP DATABASE releases it through the normal path. This mirrors the fix already applied to the doCreateOrReplaceTable cleanup path. Regression 04165 drives both failures with two ONCE failpoints (create_database_fail_after_metadata, create_database_fail_cleanup) and asserts the disk stays registered after a failed cleanup. Proven both directions on a debug build: without the commit the disk is rolled out (disk_kept 0), with it the disk is kept (disk_kept 1). Addresses a clickhouse-gh[bot] review on PR ClickHouse#103818. See issue ClickHouse#63019. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gateFor commit
Session id: cron:clickhouse-worker-slot-3:20260617-113600 |
| } | ||
| catch (...) | ||
| { | ||
| tryLogCurrentException(log, "Failed to revert durable local metadata after a failed settings ALTER"); |
There was a problem hiding this comment.
This failure path still lets the inline disk scope roll back while durable metadata may still point at the new disk. The forward write at DatabaseCatalog::alterTable above can already have persisted future_metadata locally; if this rollback alterTable throws, the catch only logs and then ~CustomDiskRegistrationScope removes the custom disk from DiskSelector / FileCacheFactory. A restart can then reload metadata that references a removed disk name, or a later DDL can reuse the name with different settings before the failed local file is repaired.
Please use the same fail-close rule as the doCreateOrReplaceTable / createDatabase cleanup paths: if the durable local-metadata rollback fails, commit/keep disk_scope before leaving the cleanup path, or otherwise prove the local file was restored before allowing the scope to roll the disk back.
…custom-disk-alter-bad-get Conflict: src/Common/FailPoint.cpp APPLY_FOR_FAILPOINTS macro (additive on both sides) resolved by keeping both sets of failpoints. Adapt StorageReplicatedMergeTree::alter to master's new lifetime-safe StorageMetadataHandle: getInMemoryMetadataPtr now returns a handle by value whose rvalue operator* is deleted, so the three 'old_metadata = *getInMemoryMetadataPtr(...)' snapshots now dereference the existing named metadata_snapshot lvalue instead (matching the future_metadata = *metadata_snapshot idiom already in this function).
The two old_metadata snapshots in the isSettingsAlter and areNonReplicatedAlterCommands branches are only read in their catch blocks, and metadata_snapshot already holds the immutable entry-time metadata for the whole function, so bind a const reference instead of copying StorageInMemoryMetadata. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
CI status for
Root cause: installing this cache server-globally with a fixed absolute path is incompatible with non-Linux runners and multi-instance (DatabaseReplicated) configs. Fix direction: scope the config to only the stateless job(s) the |
The pre-existing filesystem cache for the 04151 rollback-ownership test was installed as a server-global default cache with a hardcoded absolute path and was linked unconditionally by tests/config/install.sh. loadDefaultCaches() eagerly initializes default caches at startup, which broke two job classes: - Fast test (arm_darwin): the absolute path /var/lib/clickhouse/filesystem_caches/ is not writable on the macOS runner, so create_directories() failed with Code 36 BAD_ARGUMENTS and the server never started. The 04145/04151 tests are no-fasttest, so the config is dead weight there anyway. Gate the install link behind FAST_TEST != 1. - Stateless DatabaseReplicated: install.sh rewrites filesystem_caches_path per instance, but an absolute cache <path> ignores that and both instances locked the same .../cache_for_rollback_test/status file (Code 76 CANNOT_OPEN_FILE). Make the cache <path> relative so it resolves per-instance against each instance's data path (getPathPrefixForRelativeCachePath), matching the existing cache_for_readbigat idiom in storage_conf.xml. The 04151 test reads the resolved cache path from system.filesystem_cache_settings at runtime, so the relative path is transparent: the inline cache disk still matches the pre-existing cache by path and the rollback-ownership path (we_inserted_cache_entry == false) is still exercised. Co-Authored-By: Claude Opus 4.8 <[email protected]>
CI finish ledger — de201f8Every failed check below has an owner. Only
All other checks are green on this head: the new Session id: cron:our-pr-ci-monitor:20260626-000000 |
…custom-disk-alter-bad-get # Conflicts: # src/Storages/MergeTree/MergeTreeData.cpp
…ER checks The rejector ALTER's inline cache-wrap disk is built during validation, rolled back, then rebuilt on the apply path. When the validation build's FileCache StatusFile flock has not yet been released by its async destructor, the rebuild is rejected with CANNOT_OPEN_FILE instead of the storage-policy migration guard's BAD_ARGUMENTS. Both codes reject the ALTER and leave the table unchanged and the disk rolled back, so accept either. 04153 flaked on the slow arm_asan_ubsan azure sequential lane with alter_rejected: no while the fresh CREATE still succeeded (disk was rolled back), matching this timing race. 04152/04154/04155 share the identical rejector-ALTER pattern and get the same two-code assertion; 04150 already uses it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Pushed Root cause (from CI server log, head Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-5:20260701-161800 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 434/502 (86.45%) · Uncovered code |
CI finish ledger — 5ea3364CI has fully finished (Finish Workflow, Mergeable Check, and PR aggregators all pass; 0 checks queued/in_progress). Every failure below has an owner; only
No test-level failures at this head: all stateless/integration/stress/fuzzer/build checks are green (155 pass, 0 red test leaves). The head Session id: cron:our-pr-ci-monitor:20260701-210000 |
|
@Michicosun thanks, agreed. I validated #109199 and it correctly and completely fixes #63019. I built it locally (head e5adea5, debug) and ran the reproducer plus the cases from this PR's regression test:
Mechanism-wise it covers every call site this PR touched ( One note: #109199's test ( Closing this PR in favor of #109199 as requested. |
|
Superseded by #109199 (validated above). Closing per @Michicosun's request. |
A table created with
SETTINGS disk = disk(...)(inline custom-diskfunction) cannot be altered: every ALTER raises
Bad get: has CustomType, requested String. (BAD_GET). This happenseven on alters that do not touch the
disksetting (e.g.ADD COLUMN,MODIFY COLUMN, orMODIFY SETTINGfor any other setting), becausethe ALTER pipeline re-applies the table's
settings_changesASTthrough the validation pipeline and the parser stores
disk = disk(...)as a
CustomTypeFieldwrapping the function AST, which tripsSettingFieldString::operator=inBaseSettings::applyChanges.The CREATE path already handles this in
MergeTreeSettingsImpl::loadFromQuery: it intercepts theCustomTypefield, calls
DiskFromAST::createCustomDiskto register the inlinedisk, and replaces the value with the resulting disk-name string before
calling
applyChanges. The ALTER path skipped this conversion inseveral places.
This PR extracts the conversion into reusable helpers in
DiskFromASTand applies it in all three previously-affected ALTER call sites in
MergeTreeData:changeSettings(the actual ALTER apply path, called from bothStorageMergeTree::alterandStorageReplicatedMergeTree::alter).checkAlterIsPossible's settings-validation block, which callsMergeTreeSettings::checkCanSet,safeGet<String>, andapplyChangeson each new setting.checkColumnFilenamesForCollision(metadata, ...), called fromcheckAlterIsPossibleto enumerate per-column file names against afresh defaults instance with the new settings applied.
The two existing CREATE-path callers
(
MergeTreeSettingsImpl::loadFromQueryandDatabaseMetadataDiskSettingsImpl::loadFromQuery) are refactored touse the new helpers — pure de-duplication, no behaviour change.
Adds regression test
04145_alter_with_inline_disk_setting.sqlcovering all three throw sites:
ADD COLUMN,MODIFY COLUMN, and anon-
diskMODIFY SETTING(which still re-applies the inlinediskthrough
changeSettings).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
Bad get: has CustomType, requested Stringthrown byALTER TABLE(ADD COLUMN,MODIFY COLUMN,MODIFY SETTING, etc.) on aMergeTreetable created with an inlineSETTINGS disk = disk(...)function. Closes #63019.Documentation entry for user-facing changes