Add environment variables to override backup/restore DB settings
In the latest versions of PostgreSQL, using pg_dump on a PgBouncer
connection can cause a full GitLab outage. This happens because
pg_dump clears the search path and explicitly sets the schema for
every SQL query it runs. From https://github.com/postgres/postgres/blob/110d81728a0a006abcf654543fc15346f8043dc0/src/bin/pg_dump/pg_dump.c#L3276-L3288, pg_dump clears the search_path with the following:
SELECT pg_catalog.set_config('search_path', '', false)
When PgBouncer is used in transaction pooling mode, these connection settings persist and cause queries made by Rails
to fail since the public schema is not searched.
Currently there is no way to tell whether a connection is using
PgBouncer (https://github.com/pgbouncer/pgbouncer/issues/249), so there is no way to prevent pg_dump from running.
To avoid causing an outage, we provide admins with a way to override the database settings for the backup and restore task via environment variables:
GITLAB_BACKUP_PGHOSTGITLAB_BACKUP_PGUSERGITLAB_BACKUP_PGPORTGITLAB_BACKUP_PGPASSWORDGITLAB_BACKUP_PGSSLMODEGITLAB_BACKUP_PGSSLKEYGITLAB_BACKUP_PGSSLCERTGITLAB_BACKUP_PGSSLROOTCERTGITLAB_BACKUP_PGSSLCRLGITLAB_BACKUP_PGSSLCOMPRESSION
Relates to: