Skip to content
Snippets Groups Projects
Commit 7e8e7d61 authored by Manoj M J's avatar Manoj M J :speech_balloon:
Browse files

Add relaxed sharding keys for source_code_management

Add relaxed sharding keys for feature category `source_code_management`.

These tables have been identified as
[cell local tables](https://docs.gitlab.com/ee/development/database/multiple_databases.html#guidelines-on-choosing-between-gitlab_main_cell-and-gitlab_main_clusterwide-schema).

All cell local tables require a
[sharding key](https://docs.gitlab.com/ee/development/database/multiple_databases.html#defining-a-sharding-key-for-all-cell-local-tables).

A "relaxed" sharding key has been automatically selected for these tables, referencing either `projects` or `namespaces`, or a combination of both.

The term "relaxed" is used because:

- normally, a sharding key needs to have a NOT NULL constraint on the database.
- But, "relaxed" sharding keys do not have NOT NULL constraints. However, we have verified via database-lab that these
  columns do not contain any NULL values across any rows in the table.

This means that while the NOT NULL constraint is missing, the data itself is clean, so we can always add a NOT NULL constraint after the classification of these tables are completed.

Reviwer, please confirm that each table should indeed be cell local, and that the selected column is an appropriate
sharding key. When you are finished, please request a review from the database maintainer suggested by Danger.

If you have any questions or concerns, reach out to `@manojmj` or `@tigerwnz`.

If you would like to go through similar merged MRs so as to gather an understanding on this topic, you
can use [this](https://gitlab.com/gitlab-org/gitlab/-/merge_requests?scope=all&state=merged&label_name[]=automation%3Agitlab-housekeeper-authored) link.

This change was generated by
[gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/tree/master/gems/gitlab-housekeeper)
using the Keeps::DetermineRelaxedShardingKey keep.

To provide feedback on your experience with `gitlab-housekeeper` please comment in
<#442003>.

Changelog: other
parent 7fa722c0
No related branches found
No related tags found
1 merge request!148951Add relaxed sharding keys for source_code_management
......@@ -14,3 +14,5 @@ allow_cross_transactions:
- gitlab_main_clusterwide
allow_cross_foreign_keys:
- gitlab_main_clusterwide
sharding_key:
project_id: projects
......@@ -9,3 +9,6 @@ description: Keeps a list of protected branches by project
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/37224dc9c1ee80ba9030b616e2bc87bd96919e09
milestone: "<6.0"
gitlab_schema: gitlab_main_cell
sharding_key:
project_id: projects
namespace_id: namespaces
......@@ -26,6 +26,7 @@
*['boards.project_id', 'boards.group_id'],
'ci_pipeline_schedules.project_id',
'ci_triggers.project_id',
'gpg_signatures.project_id',
*['internal_ids.project_id', 'internal_ids.namespace_id'], # https://gitlab.com/gitlab-org/gitlab/-/issues/451900
*['labels.project_id', 'labels.group_id'], # https://gitlab.com/gitlab-org/gitlab/-/issues/434356
'member_roles.namespace_id', # https://gitlab.com/gitlab-org/gitlab/-/issues/444161
......@@ -49,7 +50,8 @@
let(:tables_with_alternative_not_null_constraint) do
[
'security_orchestration_policy_configurations.project_id',
'security_orchestration_policy_configurations.namespace_id'
'security_orchestration_policy_configurations.namespace_id',
*['protected_branches.project_id', 'protected_branches.namespace_id']
]
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment