You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/development/database/multiple_databases.md
+21-19
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ title: Multiple Databases
7
7
8
8
To allow GitLab to scale further we
9
9
[decomposed the GitLab application database into multiple databases](https://gitlab.com/groups/gitlab-org/-/epics/6168).
10
-
The main databases are `main`, `ci`, and (optionally) `sec`. GitLab supports being run with one, two, or three databases.
10
+
The main databases are `main`, `ci`, and `sec`. GitLab supports being run with one, two, or three databases.
11
11
On GitLab.com we are using separate `main``ci`, and `sec` databases.
12
12
13
13
For the purpose of building the [Cells](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/cells/) architecture, we are decomposing
@@ -68,7 +68,7 @@ The `gitlab_schema` primary purpose is to introduce a barrier between different
68
68
69
69
This is used as a primary source of classification for:
70
70
71
-
-[Discovering cross-joins across tables from different schemas](#removing-joins-between-ci-and-non-ci-tables)
71
+
-[Discovering cross-joins across tables from different schemas](#removing-joins-between-main-and-non-main-tables)
72
72
-[Discovering cross-database transactions across tables from different schemas](#removing-cross-database-transactions)
73
73
74
74
### The special purpose of `gitlab_shared`
@@ -102,7 +102,7 @@ might be missing some of those application-defined `gitlab_shared` tables (like
102
102
103
103
Read [Migrations for Multiple Databases](migrations_for_multiple_databases.md).
104
104
105
-
## CI/CD Database
105
+
## CI and Sec Databases
106
106
107
107
### Configure single database
108
108
@@ -111,7 +111,7 @@ By default, GDK is configured to run with multiple databases.
111
111
{{< alert type="warning" >}}
112
112
113
113
Switching back-and-forth between single and multiple databases in
114
-
the same development instance is discouraged. Any data in the `ci`
114
+
the same development instance is discouraged. Any data in the `ci` or `sec`
115
115
database will not be accessible in single database mode. For single database, you should use a separate development instance.
116
116
117
117
{{< /alert >}}
@@ -122,6 +122,7 @@ To configure GDK to use a single database:
122
122
123
123
```shell
124
124
gdk config set gitlab.rails.databases.ci.enabled false
125
+
gdk config set gitlab.rails.databases.sec.enabled false
125
126
```
126
127
127
128
1. Reconfigure GDK:
@@ -130,21 +131,21 @@ To configure GDK to use a single database:
130
131
gdk reconfigure
131
132
```
132
133
133
-
To switch back to using multiple databases, set `gitlab.rails.databases.ci.enabled` to `true` and run `gdk reconfigure`.
134
+
To switch back to using multiple databases, set `gitlab.rails.databases.<db_name>.enabled` to `true` and run `gdk reconfigure`.
134
135
135
136
<!--
136
137
The `validate_cross_joins!` method in `spec/support/database/prevent_cross_joins.rb` references
137
138
the following heading in the code, so if you make a change to this heading, make sure to update
138
139
the corresponding documentation URL used in `spec/support/database/prevent_cross_joins.rb`.
139
140
-->
140
141
141
-
### Removing joins between `ci` and non `ci` tables
142
+
### Removing joins between `main` and non `main` tables
142
143
143
144
Queries that join across databases raise an error. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68620)
144
145
in GitLab 14.3, for new queries only. Pre-existing queries do not raise an error.
145
146
146
-
Because GitLab can be run with multiple separate databases, referencing `ci`
147
-
tables with non `ci` tables in a single query is not possible. Therefore,
147
+
Because GitLab can be run with multiple separate databases, referencing `main`
148
+
tables with non `main` tables in a single query is not possible. Therefore,
148
149
using any kind of `JOIN` in SQL queries will not work.
149
150
150
151
#### Suggestions for removing cross-database joins
@@ -296,28 +297,28 @@ met:
296
297
1. The data does not update often (for example, the `project_id` column is almost
297
298
never updated for most tables).
298
299
299
-
One example we found was the `security_scans` table. This table has a foreign
300
-
key `security_scans.build_id` which allows you to join to the build. Therefore
300
+
One example we found was the `terraform_state_versions` table. This table has a foreign
301
+
key `terraform_state_versions.ci_build_id` which allows you to join to the build. Therefore
0 commit comments