Skip to content

Fix server failing to start once after an upgrade when all_... system log tables are replaced on startup - #127630

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-startup-drop-before-dropped-tables-recovery
Oct 23, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-startup-drop-before-dropped-tables-recovery

Conversation

@kssenii

@kssenii kssenii commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix server failing to start once after an upgrade when all_... system log tables are replaced on startup


Workflow [PR]
Sync PR [sync-upstream/pr/127630]

Version info

  • Merged into: 26.11.1.691-master (included in 26.11 and later)

kssenii and others added 2 commits October 23, 2026 17:55
…runs

When the system log tables are prepared on startup (`prepare_system_log_tables_on_startup`,
implied by `startup_scripts`), `SystemLog::prepareUnionTable` replaces an obsolete `all_...`
union table with `CREATE OR REPLACE` and drops the old one before `loadMarkedAsDroppedTables`
runs. The dropped table is queued with its storage and still holds its UUID, so
`loadMarkedAsDroppedTables` found its metadata in `metadata_dropped` and failed the startup
with `TABLE_ALREADY_EXISTS` (UUID collision). The server started on the next attempt.

Union tables are created by default since #117943, and `all_trace_log` depends on the build id,
so this happened on every upgrade of a server with `startup_scripts`.

Related: #117943
Related: #112670

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Match a file in `metadata_dropped` against the queued drops by disk and metadata path instead of
by UUID. The path contains the UUID, so a differently named file with the same UUID is a real
collision and still fails. Checking each file under `tables_marked_dropped_mutex` also covers a
drop that happens while the directory is scanned. Log each skipped table.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0641fc0]

Summary: ✅


AI Review

Summary

The PR fixes the first startup after an upgrade failing when generated all_... system log tables are replaced. Recovery skips metadata already queued for deletion in this process, matching both the disk and metadata path. A focused integration test upgrades from ClickHouse 26.8 with prepare_system_log_tables_on_startup enabled. No actionable findings in commit 0641fc0f44b5d651cbe0b73d953b188faa182341.

Missing context / blind spots
  • ⚠️ Runtime validation remains pending: the retrieved Praktika report contains no result for the new upgrade regression, and integration tests were not run locally. A completed run of test_replaced_during_upgrade would close this gap.
Final Verdict

Status: ✅ Approve. No code changes requested; runtime validation remains with CI.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 23, 2026
Start `node4` with 26.8, the first release with union tables, and upgrade it with
`restart_with_latest_version` instead of imitating an obsolete union table. `all_trace_log` contains
the build id, so every upgrade replaces it. Without the fix, the first start of the new version fails
with `TABLE_ALREADY_EXISTS` (UUID collision).

Correction to the previous commit: checking each file under the mutex narrows the window for a drop
that happens during the scan but does not close it, because `DatabaseAtomic::dropTableImpl` moves
the metadata file before it queues the table.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-system-table system.* tables (introspection, system metadata, performance visibility). label Oct 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0641fc0f4 with master db92feff7 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov self-assigned this Oct 23, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into master with commit be7f34a Oct 23, 2026
178 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-startup-drop-before-dropped-tables-recovery branch October 23, 2026 23:35
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 1, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 1, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 1, 2026
Backport #127630 to 26.10: Fix server failing to start once after an upgrade when all_... system log tables are replaced on startup
@fm4v fm4v added v26.8-must-backport and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Nov 1, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore labels Nov 2, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 2, 2026
Backport #127630 to 26.8: Fix server failing to start once after an upgrade when all_... system log tables are replaced on startup
clickhouse-gh Bot added a commit that referenced this pull request Nov 2, 2026
Backport #127630 to 26.9: Fix server failing to start once after an upgrade when all_... system log tables are replaced on startup
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…pgrade when all_... system log tables are replaced on startup
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…pgrade when all_... system log tables are replaced on startup
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…upgrade when all_... system log tables are replaced on startup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-system-table system.* tables (introspection, system metadata, performance visibility). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First start of a new build fails once with UUID collision when system.all_* union tables are replaced (fix #127630 not on release/26.10)

7 participants