Add siphon_p_vulnerability_identifiers ClickHouse table
What does this MR do and why?
MR !254763 (merged) will swap the PostgreSQL primary key of vulnerability_identifiers from (id) to (id, partition_id) as part of the list partitioning epic (issue #596859).
The Siphon replication spec (spec/db/clickhouse_siphon_tables_spec.rb) requires the ClickHouse target table's primary key to end with the PostgreSQL primary key columns, and dedup_by to match them exactly. The existing ClickHouse table siphon_vulnerability_identifiers has PRIMARY KEY (traversal_path, id), and ClickHouse cannot alter a table's primary key in place.
This MR creates a new table siphon_p_vulnerability_identifiers with PRIMARY KEY (traversal_path, id, partition_id) and migrates the data over, following the same approach used for siphon_work_item_parent_links in commit ec61b573, based on guidance from the Siphon maintainers.
Implementation
Three ClickHouse migrations:
20260911151319: createssiphon_p_vulnerability_identifiers. Generated withbundle exec rails generate gitlab:click_house:siphon vulnerability_identifiers --with-traversal-pathagainst a database that already had the composite primary key applied, then renamed.20260911151320: creates a materialized viewsiphon_p_vulnerability_identifiers_mvthat pipes new writes fromsiphon_vulnerability_identifiersinto the new table, so replication keeps landing in both tables during and after the backfill.20260911151321: backfills existing rows usingClickHouse::Iteratorin 500k row batches. Duplicates from the overlap with the MV are collapsed by the ReplacingMergeTree engine. The down migration is a no-op since re-running the copy is idempotent.
What's deliberately not in this MR
db/siphon/tables/vulnerability_identifiers.ymlis not repointed here. The spec requiresdedup_byto equal the live PostgreSQL primary key, so that config change (pointing atsiphon_p_vulnerability_identifierswithdedup_by: [id, partition_id]) ships together with the PostgreSQL primary key swap in !254763 (merged). That MR depends on this one.- Dropping the old
siphon_vulnerability_identifierstable and its materialized view is left for a follow-up cleanup MR after !254763 (merged) merges.
How to set up and validate locally
- Migrations were run against a real ClickHouse 25.12 container.
db/click_house/main.sqland the schema cache YAML were regenerated using the actualgitlab:clickhouse:schema:dump:maintooling. spec/db/clickhouse_siphon_tables_spec.rb: 79 examples, 0 failuresspec/scripts/click_house/schema_validator_spec.rb: 92 examples, 0 failures- RuboCop clean
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- I have evaluated the MR acceptance checklist for this MR.