Ci Resouce Group models and parser (with migration fix)
What does this MR do?
This MR cherry picks the reverted commit due to a migration failure. The problem is explained well in https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/8718#note_261176518 and !20950 (comment 261142220). But simply put,
- We should not create a FK to a big table in transaction because it locks the table and make some queries (e.g.
UPDATE
) wait. - We should not execute FK creation and column addition to the same table in the same transaction because it causes deadlock.
Previously we had these migrations:
-
db/migrate/20191128145231_add_ci_resource_groups.rb
... It createsci_resource_groups
andci_resources
. It adds FKs to thebuild_id
andproject_id
columns. It also addsresource_group_id
andwaiting_for_resource_at
columns toci_builds
. All happens in a single transaction thus failed. -
db/migrate/20191129144631_add_index_to_resource_group_id.rb
... It adds FK and index toci_builds.resource_group_id
toci_resource_groups
table.
And this MR introduces the following migrations, instead. Basically, splitting the 20191128145231_add_ci_resource_groups
into four migrations. See
-
db/migrate/20191128145231_add_ci_resource_groups.rb
... It createsci_resource_groups
andci_resources
tables in transaction. It doesn't add FK at this moment. -
db/migrate/20191128145232_add_fk_to_ci_resources_build_id.rb
... It adds FK toci_resources.build_id
toci_builds
table withadd_concurrent_foreign_key
. -
db/migrate/20191128145233_add_fk_to_ci_resource_groups_project_id.rb
... It adds FK toci_resource_groups.project_id
toprojects
table withadd_concurrent_foreign_key
. -
db/migrate/20191129144630_add_resource_group_id_to_ci_builds.rb
... It addsresource_group_id
andwaiting_for_resource_at
columns toci_builds
in transaction. -
db/migrate/20191129144631_add_index_to_resource_group_id.rb
... It adds FK and index toci_builds.resource_group_id
toci_resource_groups
table.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
Edited by Mayra Cabrera