Backport of 'Fix ci_finished_builds engine swap on deferred post-deploy' into 18.11
What does this MR do and why?
Backports !240219 (merged), !240627 (merged), and !240798 (merged) (merged commit b4f205d5) to 18-11-stable-ee.
ClickHouse post-deployment migration 20260108073937_alter_ci_finished_builds_engine_with_version failed in three ways on stable branches that run ClickHouse 23.x/24.x:
-
Structure mismatch (#593129 (closed)):
Code: 122. DB::Exception: Tables have different structure. (INCOMPATIBLE_COLUMNS)when self-managed customers upgrade from 18.8.x to 18.9.x–19.0.x. Root cause: hardcodedCREATE TABLEfor the tmp table; later-timestamped migrations add columns/projections before this post-deploy migration runs. Fixed in master by !240219 (merged). -
Missing PARTITION BY / ORDER BY on CH 23.x/24.x:
Code: 36 BAD_ARGUMENTSbecause theCREATE TABLE … AS source ENGINE = …form does not implicitly inherit those from the source on older ClickHouse. Fixed in master by !240627 (merged) (specified explicitly). -
drop_tmp_tableUNKNOWN_SETTING on CH 23.x:SETTINGS max_table_size_to_drop = 0is only valid as a query-level setting on CH 24.0+; on CH 23.x it raisesCode: 115 UNKNOWN_SETTING. Worse, simply omitting it would fail DROP for any customer with >50 GB in tmp. Fixed in master by !240798 (merged): on CH 23.x DETACH every partition first (size check does not apply), then DROP the empty table.
This branch contains three cherry-picks from master:
| commit | from MR | purpose |
|---|---|---|
ca503ffb |
!240219 (merged) | Initial fix: clone source structure via CREATE TABLE … AS source |
d811b49f |
!240627 (merged) | Explicit PARTITION BY / ORDER BY for CH 23.x/24.x compatibility |
b4f205d5 |
!240798 (merged) | DETACH+DROP for CH 23.x, version-agnostic spec, dedup-gate threshold corrected to CH 24.8+, self-healing create_tmp_table, and a .pluck('name') rubocop fix for rubocop-rails 2.26+. |
Verified end-to-end on CH 23.11.3, 24.9.1 and 25.x via docker — full migration sequence succeeds; row count preserved; engine swapped from ReplacingMergeTree(deleted) to ReplacingMergeTree(version, deleted).
References
- Issue: #593129 (closed) (
severity::2,priority::2,Customer Interest,GitLab Dedicated) - Master MRs: !240219 (merged), !240627 (merged), !240798 (merged)
- Customer ticket: ZD#700951
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
- The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
- The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
- Required labels have been applied to this merge request
- severity label and bug subtype labels (if applicable)
- If this MR fixes a bug that affects customers, the customer label has been applied.
- This MR has been approved by a maintainer (only one approval is required).
- Ensure the
e2e:test-on-omnibus-eejob has succeeded, or if it has failed, investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.
Note to the merge request author and maintainer
If you have questions about the patch release process, please:
- Refer to the patch release runbook for engineers and maintainers for guidance.
- Ask questions on the
#releasesSlack channel (internal only). - Once the backport has been merged, the commit changes will be automatically deployed to a release environment that can be used for manual validation. See after merging runbook for details.