mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06: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:
10
repmgr.c
10
repmgr.c
@@ -2368,7 +2368,7 @@ static bool
|
|||||||
copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
||||||
{
|
{
|
||||||
char sqlquery[MAXLEN];
|
char sqlquery[MAXLEN];
|
||||||
PGresult *res;
|
PGresult *res, *res_witness;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
||||||
@@ -2401,15 +2401,17 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
|||||||
atoi(PQgetvalue(res, i, 3)),
|
atoi(PQgetvalue(res, i, 3)),
|
||||||
PQgetvalue(res, i, 4));
|
PQgetvalue(res, i, 4));
|
||||||
|
|
||||||
res = PQexec(witnessconn, sqlquery);
|
res_witness = PQexec(witnessconn, sqlquery);
|
||||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (!res_witness || PQresultStatus(res_witness) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot copy configuration to witness, %s\n",
|
fprintf(stderr, "Cannot copy configuration to witness, %s\n",
|
||||||
PQerrorMessage(witnessconn));
|
PQerrorMessage(witnessconn));
|
||||||
PQclear(res);
|
PQclear(res_witness);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
PQclear(res_witness);
|
||||||
}
|
}
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ witness_monitor(void)
|
|||||||
sqlquery_snprintf(sqlquery,
|
sqlquery_snprintf(sqlquery,
|
||||||
"INSERT INTO %s.repl_monitor "
|
"INSERT INTO %s.repl_monitor "
|
||||||
"VALUES(%d, %d, '%s'::timestamp with time zone, "
|
"VALUES(%d, %d, '%s'::timestamp with time zone, "
|
||||||
" pg_current_xlog_location(), null, "
|
" null, pg_current_xlog_location(), null, "
|
||||||
" 0, 0)",
|
" 0, 0)",
|
||||||
repmgr_schema, primary_options.node, local_options.node,
|
repmgr_schema, primary_options.node, local_options.node,
|
||||||
monitor_witness_timestamp);
|
monitor_witness_timestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user