Add new config to ensure backup/restore connects to PG directly.
* In `pg_dump` 10.3+ and 9.5.12+, in it does a `SELECT pg_catalog.set_config('search_path', '', false)` which changes the state of the current connection. This is known to be problematic with Pgbouncer which reuses connections. As such, we'll always try to connect directly to PG directly during the backup/restore process.
This commit is contained in:
parent
5b6e49ae1d
commit
a89f3160a5
|
@ -92,7 +92,21 @@ class GlobalSetting
|
|||
|
||||
def self.database_config
|
||||
hash = { "adapter" => "postgresql" }
|
||||
%w{pool connect_timeout timeout socket host port username password replica_host replica_port}.each do |s|
|
||||
|
||||
%w{
|
||||
pool
|
||||
connect_timeout
|
||||
timeout
|
||||
socket
|
||||
host
|
||||
backup_host
|
||||
port
|
||||
backup_port
|
||||
username
|
||||
password
|
||||
replica_host
|
||||
replica_port
|
||||
}.each do |s|
|
||||
if val = self.send("db_#{s}")
|
||||
hash[s] = val
|
||||
end
|
||||
|
|
|
@ -30,9 +30,16 @@ db_socket =
|
|||
# This is set to blank so it tries to use sockets first
|
||||
db_host =
|
||||
|
||||
# host address for db server when taking a backup via `pg_dump`
|
||||
# Defaults to `db_host` if not configured
|
||||
db_backup_host =
|
||||
|
||||
# port running db server, no need to set it
|
||||
db_port =
|
||||
|
||||
# db server port to use when taking a backup via `pg_dump`
|
||||
db_backup_port = 5432
|
||||
|
||||
# database name running discourse
|
||||
db_name = discourse
|
||||
|
||||
|
|
|
@ -110,8 +110,8 @@ module BackupRestore
|
|||
config = config.with_indifferent_access
|
||||
|
||||
DatabaseConfiguration.new(
|
||||
config["host"],
|
||||
config["port"],
|
||||
config["backup_host"] || config["host"],
|
||||
config["backup_port"] || config["port"],
|
||||
config["username"] || ENV["USER"] || "postgres",
|
||||
config["password"],
|
||||
config["database"]
|
||||
|
|
Loading…
Reference in New Issue