mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
fix: witness creation and monitoring
While reading node entries from master use a separate PGresult when inserting into witness. Witness monitoring supplies a null value for 'last_apply_time'.
This commit is contained in:
committed by
Jaime Casanova
parent
30ccee43d9
commit
c23e5858f2
10
repmgr.c
10
repmgr.c
@@ -2324,7 +2324,7 @@ static bool
|
||||
copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
||||
{
|
||||
char sqlquery[MAXLEN];
|
||||
PGresult *res;
|
||||
PGresult *res, *res_witness;
|
||||
int i;
|
||||
|
||||
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
||||
@@ -2357,15 +2357,17 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
||||
atoi(PQgetvalue(res, i, 3)),
|
||||
PQgetvalue(res, i, 4));
|
||||
|
||||
res = PQexec(witnessconn, sqlquery);
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
res_witness = PQexec(witnessconn, sqlquery);
|
||||
if (!res_witness || PQresultStatus(res_witness) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "Cannot copy configuration to witness, %s\n",
|
||||
PQerrorMessage(witnessconn));
|
||||
PQclear(res);
|
||||
PQclear(res_witness);
|
||||
return false;
|
||||
}
|
||||
PQclear(res_witness);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ witness_monitor(void)
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"INSERT INTO %s.repl_monitor "
|
||||
"VALUES(%d, %d, '%s'::timestamp with time zone, "
|
||||
" pg_current_xlog_location(), null, "
|
||||
" null, pg_current_xlog_location(), null, "
|
||||
" 0, 0)",
|
||||
repmgr_schema, primary_options.node, local_options.node,
|
||||
monitor_witness_timestamp);
|
||||
|
||||
Reference in New Issue
Block a user