Skip to content

Ensure id uniquness across p_ci_builds partitions

Marius Bobin requested to merge 394704-test-id-uniqueness into master

What does this MR do and why?

This ensures the id uniqueness across partitions without having other tables. This relies on the fact that sequences generate distinct values and it changes the assignment order to prevent the users from assigning the value.

How to set up and validate locally

  1. ./scripts/regenerate-schema - regenerate the test database and run the migrations
  2. gdk psql -d gitlabhq_test_ci - start a psql session to the CI test database
  3. insert into p_ci_builds(project_id, partition_id) values (1, 100) returning id; - insert a record without id
  4. select id, partition_id from p_ci_builds; - confirm that the id was assigned
  5. insert into p_ci_builds(project_id, partition_id, id) values (1, 100, 1000) returning id; - insert a row with a specific id value and see a message like:
gitlabhq_test_ci=# insert into p_ci_builds(project_id, partition_id, id) values (1, 100, 1000) returning id;
WARNING:  Manually assigning ids is not allowed, the value will be ignored
 id
----
  4
(1 row)

INSERT 0 1

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #394704 (closed)

Edited by Marius Bobin

Merge request reports