• Stan Hu's avatar
    Add environment variables to override backup/restore DB settings · 93e04700
    Stan Hu authored
    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. 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, 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_PGHOST`
    * `GITLAB_BACKUP_PGUSER`
    * `GITLAB_BACKUP_PGPORT`
    * `GITLAB_BACKUP_PGPASSWORD`
    * `GITLAB_BACKUP_PGSSLMODE`
    * `GITLAB_BACKUP_PGSSLKEY`
    * `GITLAB_BACKUP_PGSSLCERT`
    * `GITLAB_BACKUP_PGSSLROOTCERT`
    * `GITLAB_BACKUP_PGSSLCRL`
    * `GITLAB_BACKUP_PGSSLCOMPRESSION`
    
    Relates to:
    
    * https://gitlab.com/gitlab-org/gitlab/-/issues/23211
    * https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/3470
    93e04700
backup_restore.md 47.2 KB