Add PgBouncer search_path as `ignored startup parameter`

If a user attempts to backup GitLab through PgBouncer, this can cause
a full site outage since pg_dump will alter the PostgreSQL search
path, as documented in
https://docs.gitlab.com/ee/administration/postgresql/pgbouncer.html#backups
and
https://docs.gitlab.com/ee/administration/backup_restore/backup_gitlab.html#back-up-and-restore-for-installations-using-pgbouncer.

To avoid causing an outage, make PgBouncer ignore the `search_path`
startup parameter by default.

Relates to https://github.com/pgbouncer/pgbouncer/issues/89

Changelog: changed
This commit is contained in:
Stan Hu 2024-04-23 10:27:29 -07:00
parent 0643e43b70
commit 438b4d468a
No known key found for this signature in database
GPG Key ID: 8D3931AD39CC7A20
4 changed files with 6 additions and 6 deletions

View File

@ -3131,7 +3131,7 @@ external_url 'GENERATED_EXTERNAL_URL'
# pgbouncer['dns_nxdomain_ttl'] = '15.0'
# pgbouncer['admin_users'] = %w(gitlab-psql postgres pgbouncer)
# pgbouncer['stats_users'] = %w(gitlab-psql postgres pgbouncer)
# pgbouncer['ignore_startup_parameters'] = 'extra_float_digits'
# pgbouncer['ignore_startup_parameters'] = %w(extra_float_digits search_path)
# pgbouncer['track_extra_parameters'] = %w(IntervalStyle)
# pgbouncer['databases'] = {
# DATABASE_NAME: {

View File

@ -24,7 +24,7 @@ default['pgbouncer']['dns_zone_check_period'] = 0
default['pgbouncer']['dns_nxdomain_ttl'] = '15.0'
default['pgbouncer']['admin_users'] = %w(gitlab-psql postgres pgbouncer)
default['pgbouncer']['stats_users'] = %w(gitlab-psql postgres pgbouncer)
default['pgbouncer']['ignore_startup_parameters'] = 'extra_float_digits'
default['pgbouncer']['ignore_startup_parameters'] = %w(extra_float_digits search_path)
default['pgbouncer']['track_extra_parameters'] = %w(IntervalStyle)
default['pgbouncer']['databases_ini'] = '/var/opt/gitlab/pgbouncer/databases.ini'
default['pgbouncer']['databases_ini_user'] = 'root'

View File

@ -51,7 +51,7 @@ RSpec.describe PgbouncerHelper do
expect(ini_config['listen_addr']).to eq('0.0.0.0')
expect(ini_config['listen_port']).to eq(6432)
expect(ini_config['data_directory']).to eq('/var/opt/gitlab/pgbouncer')
expect(ini_config['ignore_startup_parameters']).to eq('extra_float_digits')
expect(ini_config['ignore_startup_parameters']).to eq('extra_float_digits, search_path')
end
end
@ -61,7 +61,7 @@ RSpec.describe PgbouncerHelper do
pgbouncer: {
listen_port: 1234,
data_directory: '/tmp',
ignore_startup_parameters: %w[extra_float_digits search_path]
ignore_startup_parameters: %w[extra_float_digits]
}
)
end
@ -71,7 +71,7 @@ RSpec.describe PgbouncerHelper do
expect(ini_config['listen_addr']).to eq('0.0.0.0')
expect(ini_config['listen_port']).to eq(1234)
expect(ini_config['data_directory']).to eq('/tmp')
expect(ini_config['ignore_startup_parameters']).to eq('extra_float_digits, search_path')
expect(ini_config['ignore_startup_parameters']).to eq('extra_float_digits')
end
end

View File

@ -90,7 +90,7 @@ RSpec.describe 'pgbouncer' do
expect(content).to match(%r{^auth_file = /var/opt/gitlab/pgbouncer/pg_auth$})
expect(content).to match(/^admin_users = gitlab-psql, postgres, pgbouncer$/)
expect(content).to match(/^stats_users = gitlab-psql, postgres, pgbouncer$/)
expect(content).to match(/^ignore_startup_parameters = extra_float_digits$/)
expect(content).to match(/^ignore_startup_parameters = extra_float_digits, search_path$/)
expect(content).to match(/^track_extra_parameters = IntervalStyle$/)
expect(content).to match(%r{^unix_socket_dir = /var/opt/gitlab/pgbouncer$})
expect(content).to match(%r{^%include /var/opt/gitlab/pgbouncer/databases.ini})