mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
Add "dbname=replication" to all replication connection strings
Previously repmgr was attempting to make replication connections with "dbname" set to the repmgr database name. While this works if e.g. the repmgr user also has replication permissions, it will fail if a dedicated replication user is specified, who only has permission to access the virtual "replication" database. Change this to use "dbname=replication" if the replication connection user is different to the normal repmgr database user. (We could just always set it to "replication", but that might break existing installations e.g. where a .pgpass file is in use and there's no "replication" entry for the normal repmgr database user). Addresses GitHub #421.
This commit is contained in:
@@ -940,6 +940,7 @@ do_node_check_replication_connection(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* retrieve remote node record from local database */
|
||||
local_conn = establish_db_connection(config_file_options.conninfo, true);
|
||||
|
||||
record_status = get_node_record(local_conn, runtime_options.remote_node_id, &node_record);
|
||||
@@ -956,8 +957,12 @@ do_node_check_replication_connection(void)
|
||||
initialize_conninfo_params(&remote_conninfo, false);
|
||||
parse_conninfo_string(node_record.conninfo, &remote_conninfo, NULL, false);
|
||||
|
||||
if (strcmp(param_get(&remote_conninfo, "user"), node_record.repluser) != 0)
|
||||
{
|
||||
param_set(&remote_conninfo, "user", node_record.repluser);
|
||||
param_set(&remote_conninfo, "dbname", "replication");
|
||||
}
|
||||
param_set(&remote_conninfo, "replication", "1");
|
||||
param_set(&remote_conninfo, "user", node_record.repluser);
|
||||
|
||||
repl_conn = establish_db_connection_by_params(&remote_conninfo, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user