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

Edited by Rehab

Merge request reports

Loading