Commit 3d65382f authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'bprescott/docs/20210513-database' into 'master'

PostgreSQL documentation revisions

See merge request gitlab-org/gitlab!61783
parents 668e6649 d51593de
...@@ -23,6 +23,9 @@ If you use a cloud-managed service, or provide your own PostgreSQL instance: ...@@ -23,6 +23,9 @@ If you use a cloud-managed service, or provide your own PostgreSQL instance:
- Amazon RDS requires the [`rds_superuser`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.Roles) role. - Amazon RDS requires the [`rds_superuser`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.Roles) role.
- Azure Database for PostgreSQL requires the [`azure_pg_admin`](https://docs.microsoft.com/en-us/azure/postgresql/howto-create-users#how-to-create-additional-admin-users-in-azure-database-for-postgresql) role. - Azure Database for PostgreSQL requires the [`azure_pg_admin`](https://docs.microsoft.com/en-us/azure/postgresql/howto-create-users#how-to-create-additional-admin-users-in-azure-database-for-postgresql) role.
This is for the installation of extensions during installation and upgrades. As an alternative,
[ensure the extensions are installed manually, and read about the problems that may arise during future GitLab upgrades](../../install/postgresql_extensions.md).
1. Configure the GitLab application servers with the appropriate connection details 1. Configure the GitLab application servers with the appropriate connection details
for your external PostgreSQL service in your `/etc/gitlab/gitlab.rb` file: for your external PostgreSQL service in your `/etc/gitlab/gitlab.rb` file:
......
...@@ -54,7 +54,19 @@ In order to install a PostgreSQL extension, this procedure should be followed: ...@@ -54,7 +54,19 @@ In order to install a PostgreSQL extension, this procedure should be followed:
On some systems you may need to install an additional package (for example, On some systems you may need to install an additional package (for example,
`postgresql-contrib`) for certain extensions to become available. `postgresql-contrib`) for certain extensions to become available.
## A typical migration failure scenario ## Typical failure scenarios
The following is an example of a new GitLab installation failing because the extension hasn't been
installed first.
```shell
---- Begin output of "bash" "/tmp/chef-script20210513-52940-d9b1gs" ----
STDOUT: psql:/opt/gitlab/embedded/service/gitlab-rails/db/structure.sql:9: ERROR: permission denied to create extension "btree_gist"
HINT: Must be superuser to create this extension.
rake aborted!
failed to execute:
psql -v ON_ERROR_STOP=1 -q -X -f /opt/gitlab/embedded/service/gitlab-rails/db/structure.sql --single-transaction gitlabhq_production
```
The following is an example of a situation when the extension hasn't been installed before running migrations. The following is an example of a situation when the extension hasn't been installed before running migrations.
In this scenario, the database migration fails to create the extension `btree_gist` because of insufficient In this scenario, the database migration fails to create the extension `btree_gist` because of insufficient
...@@ -79,5 +91,9 @@ This query will grant the user superuser permissions, ensuring any database exte ...@@ -79,5 +91,9 @@ This query will grant the user superuser permissions, ensuring any database exte
can be installed through migrations. can be installed through migrations.
``` ```
In order to recover from this situation, the extension needs to be installed manually using a superuser, and To recover from failed migrations, the extension must be installed manually by a superuser, and the
the database migration (or GitLab upgrade) can be retried afterwards. GitLab upgrade completed by [re-running the database migrations](../administration/raketasks/maintenance.md#run-incomplete-database-migrations):
```shell
sudo gitlab-rake db:migrate
```
...@@ -117,13 +117,14 @@ the following table) as these were used for development and testing: ...@@ -117,13 +117,14 @@ the following table) as these were used for development and testing:
| 10.0 | 9.6 | | 10.0 | 9.6 |
| 13.0 | 11 | | 13.0 | 11 |
You must also ensure the following extensions are [loaded into every You must also ensure the following extensions are loaded into every
GitLab database](postgresql_extensions.html): GitLab database. [Read more about this requirement, and troubleshooting](postgresql_extensions.md).
| Extension | Minimum GitLab version | | Extension | Minimum GitLab version |
| ------------ | ---------------------- | | ------------ | ---------------------- |
| `pg_trgm` | 8.6 | | `pg_trgm` | 8.6 |
| `btree_gist` | 13.1 | | `btree_gist` | 13.1 |
| `plpgsql` | 11.7 |
NOTE: NOTE:
Support for [PostgreSQL 9.6 and 10 was removed in GitLab 13.0](https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-released/#postgresql-11-is-now-the-minimum-required-version-to-install-gitlab) so that GitLab can benefit from PostgreSQL 11 improvements, such as partitioning. For the schedule of transitioning to PostgreSQL 12, see [the related epic](https://gitlab.com/groups/gitlab-org/-/epics/2184). Support for [PostgreSQL 9.6 and 10 was removed in GitLab 13.0](https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-released/#postgresql-11-is-now-the-minimum-required-version-to-install-gitlab) so that GitLab can benefit from PostgreSQL 11 improvements, such as partitioning. For the schedule of transitioning to PostgreSQL 12, see [the related epic](https://gitlab.com/groups/gitlab-org/-/epics/2184).
...@@ -136,6 +137,35 @@ test based on those. We try to be compatible with most external (not managed by ...@@ -136,6 +137,35 @@ test based on those. We try to be compatible with most external (not managed by
Omnibus GitLab) databases (for example, [AWS Relational Database Service (RDS)](https://aws.amazon.com/rds/)), Omnibus GitLab) databases (for example, [AWS Relational Database Service (RDS)](https://aws.amazon.com/rds/)),
but we can't guarantee compatibility. but we can't guarantee compatibility.
#### Gitaly Cluster database requirements
[Read more in the Gitaly Cluster documentation](../administration/gitaly/praefect.md).
#### Exclusive use of GitLab databases
Databases created or used for GitLab, Geo, Gitaly Cluster, or other components should be for the
exclusive use of GitLab. Do not make direct changes to the database, schemas, users, or other
properties except when following procedures in the GitLab documentation or following the directions
of GitLab Support or other GitLab engineers.
- The main GitLab application currently uses three schemas:
- The default `public` schema
- `gitlab_partitions_static` (automatically created)
- `gitlab_partitions_dynamic` (automatically created)
No other schemas should be manually created.
- GitLab may create new schemas as part of Rails database migrations. This happens when performing
a GitLab upgrade. The GitLab database account requires access to do this.
- GitLab creates and modifies tables during the upgrade process, and also as part of normal
operations to manage partitioned tables.
- You should not modify the GitLab schema (for example, adding triggers or modifying tables).
Database migrations are tested against the schema definition in the GitLab code base. GitLab
version upgrades may fail if the schema is modified.
## Puma settings ## Puma settings
The recommended settings for Puma are determined by the infrastructure on which it's running. The recommended settings for Puma are determined by the infrastructure on which it's running.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment