Make sure the shards table has its index created before populating it
What does this MR do?
This fixes a race-condition discovered in #212436 (closed).
Shards are populated in an initializer, which would run in any container that runs GitLab and tries to start it up: https://gitlab.com/gitlab-org/gitlab/-/blob/dc17873201097e7d4838f6be9211f5945c96ec1e/config/initializers/fill_shards.rb#L3
So as soon as Active Record is connected and the shards
table exists and the database isn't read-only, shards are being populated, which could occur after the shards
is created by db:structure:load
but before the index_shards_on_name
is created (since indexes are located at the end of structure.sql
)!
This MR ensure the shards
population can only happen after the unique index on name
is created.
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
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #212436 (closed).