Replace EXCHANGE TABLES with safe_table_swap for gVisor compatibility
Summary
Fixes ClickHouse migration failures on gVisor runners by replacing EXCHANGE TABLES with a conditional safe_table_swap() method.
Problem
ClickHouse 24.10+ EXCHANGE TABLES uses the renameat2() syscall which gVisor doesn't support, causing migration failures.
Solution
Added safe_table_swap() helper that:
-
In CI: Uses
RENAME TABLE(3-way swap, gVisor-compatible, non-atomic) -
In production: Uses
EXCHANGE TABLES(atomic operation)
Also fixed nil-safety bug in migration rollback.
Testing
Tested in gl-gv project: gitlab-org/production-engineering/runners-platform/gl-gv!5
Related
- Work item: gitlab-com/gl-infra/production-engineering#28316
- gVisor issue: https://github.com/google/gvisor/issues/7895
Edited by Rehab