mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
get_master_connection(): order node list by node type and priority
This should make it more likely that the actual primary is first in the retrieved list, reducing the number of connections to other nodes in the cluster which need to be made.
This commit is contained in:
12
dbutils.c
12
dbutils.c
@@ -601,14 +601,16 @@ get_master_connection(PGconn *standby_conn, char *cluster,
|
||||
}
|
||||
|
||||
/* find all nodes belonging to this cluster */
|
||||
log_info(_("finding node list for cluster '%s'\n"),
|
||||
log_info(_("retrieving node list for cluster '%s'\n"),
|
||||
cluster);
|
||||
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT id, conninfo "
|
||||
" FROM %s.repl_nodes "
|
||||
" WHERE cluster = '%s' "
|
||||
" AND type != 'witness' ",
|
||||
" SELECT id, conninfo, "
|
||||
" CASE WHEN type = 'master' THEN 1 ELSE 2 END AS type_priority"
|
||||
" FROM %s.repl_nodes "
|
||||
" WHERE cluster = '%s' "
|
||||
" AND type != 'witness' "
|
||||
"ORDER BY type_priority, priority, active, id",
|
||||
get_repmgr_schema_quoted(standby_conn),
|
||||
cluster);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user