Ensure id uniquness across p_ci_builds partitions
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
-
./scripts/regenerate-schema
- regenerate the test database and run the migrations -
gdk psql -d gitlabhq_test_ci
- start apsql
session to the CI test database -
insert into p_ci_builds(project_id, partition_id) values (1, 100) returning id;
- insert a record without id -
select id, partition_id from p_ci_builds;
- confirm that theid
was assigned -
insert into p_ci_builds(project_id, partition_id, id) values (1, 100, 1000) returning id;
- insert a row with a specificid
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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #394704 (closed)
Edited by Marius Bobin