diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-28 21:10:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-28 21:10:13 +0000 |
commit | 8f016fe5fb42704dd949e77859888fcd898fd985 (patch) | |
tree | 32c3c311c5fb330769601b2cf684aebe6f102196 /doc/development/database | |
parent | e4632f4c63eae7ec36243d11b23d69b4fd880830 (diff) | |
download | gitlab-ce-8f016fe5fb42704dd949e77859888fcd898fd985.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/database')
-rw-r--r-- | doc/development/database/multiple_databases.md | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/doc/development/database/multiple_databases.md b/doc/development/database/multiple_databases.md new file mode 100644 index 00000000000..dbc8ab0f215 --- /dev/null +++ b/doc/development/database/multiple_databases.md @@ -0,0 +1,104 @@ +--- +stage: Enablement +group: Sharding +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Multiple Databases + +In order to scale GitLab, the GitLab application database +will be [decomposed into multiple +databases](https://gitlab.com/groups/gitlab-org/-/epics/6168). + +## CI Database + +Support for configuring the GitLab Rails application to use a distinct +database for CI tables was added in [GitLab +14.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64289). This +feature is still under development, and is not ready for production use. + +By default, GitLab is configured to use only one main database. To +opt-in to use a main database, and CI database, modify the +`config/database.yml` file to have a `primary` and a `ci` database +configurations. For example, given a `config/database.yml` like below: + +```yaml +development: + adapter: postgresql + encoding: unicode + database: gitlabhq_development + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s + +test: &test + adapter: postgresql + encoding: unicode + database: gitlabhq_test + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s +``` + +Edit the `config/database.yml` to look like this: + +```yaml +development: + primary: + adapter: postgresql + encoding: unicode + database: gitlabhq_development + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s + ci: + adapter: postgresql + encoding: unicode + database: gitlabhq_development_ci + migrations_paths: db/ci_migrate + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s + +test: &test + primary: + adapter: postgresql + encoding: unicode + database: gitlabhq_test + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s + ci: + adapter: postgresql + encoding: unicode + database: gitlabhq_test_ci + migrations_paths: db/ci_migrate + host: /path/to/gdk/postgresql + pool: 10 + prepared_statements: false + variables: + statement_timeout: 120s +``` + +Note that we use `primary` in the `config/database.yml` to refer to the main +database. This is to match the default name Rails has. + +### Migrations + +Any migrations that affect `Ci::ApplicationRecord` models +and their tables must be placed in two directories for now: + +- `db/migrate` +- `db/ci_migrate` + +We aim to keep the schema for both tables the same across both databases. |