Cleanup lazy-generation for Ci::Runner#uuid

🤖 Posted by AI Agent on behalf of Tomasz


What does this MR do and why?

Cleanup lazy-generation for Ci::Runner#uuid

Follow-up for Add UUID for ci_runners entities (!235296 - merged) and Finalize BBM BackfillCiRunnersUuid (!251000 - merged).

It removes the temporary lazy-generation that was added to ensure each Ci::Runner has an uuid, even if the BBM backfill didn't reach a record yet.

The backfill is finalized since 19.4 and the 19.5 required stop has passed, so every runner has a uuid. Instead of the lazy getter, the invariant is now enforced by the databases:

  • PostgreSQL: db/post_migrate/20261028125150_add_not_null_constraint_to_ci_runners_uuid.rb adds a NOT NULL check constraint on ci_runners.uuid (propagated to all partitions). The table is table_size: small, so the constraint is validated in the same migration.
  • ClickHouse: db/click_house/post_migrate/main/20261028130500_make_siphon_ci_runners_uuid_non_nullable.rb changes siphon_ci_runners.uuid from Nullable(UUID) to UUID, as requested in !235296 (comment 3515462584). Stale NULL rows left from before the backfill are set to the zero UUID first: ClickHouse < 25.12 fails the type change on NULLs, and >= 25.12 requires an explicit DEFAULT. Tested on 25.1.8.25 and 26.2.13.2 (the versions used in CI).

References

Rollback

  • PostgreSQL: down removes the check constraint. No data is changed.
  • ClickHouse: down restores uuid Nullable(UUID) without a default. Zero UUIDs written by up are not reverted to NULL: they carry the same "no uuid" meaning, and reverting them would need another data-rewriting mutation. This is noted in the migration.
  • Application code: reverting this MR brings back the lazy getter, which is safe with either database state.

Screenshots or screen recordings

N/A - no UI changes.

How to set up and validate locally

  1. Run the PostgreSQL migration and check the constraint:
    bin/rails db:migrate
    SELECT conrelid::regclass, conname FROM pg_constraint WHERE conname = 'check_55f3874e19';
  2. With ClickHouse configured, run the ClickHouse migrations and check the column:
    bundle exec rake gitlab:clickhouse:migrate
    SHOW CREATE TABLE siphon_ci_runners;

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Tomasz Maczukin

Merge request reports

Loading
Loading