mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Replace magic number with defined constant
And use it to restrict the number of rows retrieved to avoid overflowing the array.
This commit is contained in:
2
repmgr.h
2
repmgr.h
@@ -46,6 +46,8 @@
|
||||
#define DEFAULT_DBNAME "postgres"
|
||||
#define DEFAULT_REPMGR_SCHEMA_PREFIX "repmgr_"
|
||||
|
||||
#define FAILOVER_NODES_MAX_CHECK 50
|
||||
|
||||
#define MANUAL_FAILOVER 0
|
||||
#define AUTOMATIC_FAILOVER 1
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
/*
|
||||
* MAIN LOOP This loops cicles once per failover and at startup
|
||||
* MAIN LOOP This loops cycles at startup and once per failover and
|
||||
* Requisites: - my_local_conn needs to be already setted with an active
|
||||
* connection - no master connection
|
||||
*/
|
||||
@@ -782,7 +782,7 @@ do_failover(void)
|
||||
* will get info about until 50 nodes, which seems to be large enough for
|
||||
* most scenarios
|
||||
*/
|
||||
t_node_info nodes[50];
|
||||
t_node_info nodes[FAILOVER_NODES_MAX_CHECK];
|
||||
|
||||
/* initialize to keep compiler quiet */
|
||||
t_node_info best_candidate = {-1, "", InvalidXLogRecPtr, false, false, false};
|
||||
@@ -791,8 +791,8 @@ do_failover(void)
|
||||
sprintf(sqlquery, "SELECT id, conninfo, witness "
|
||||
" FROM %s.repl_nodes "
|
||||
" WHERE cluster = '%s' "
|
||||
" ORDER BY priority, id ",
|
||||
repmgr_schema, local_options.cluster_name);
|
||||
" ORDER BY priority, id LIMIT %i",
|
||||
repmgr_schema, local_options.cluster_name, FAILOVER_NODES_MAX_CHECK);
|
||||
|
||||
res = PQexec(my_local_conn, sqlquery);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
|
||||
Reference in New Issue
Block a user