mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Ensure event logging doesn't generate an error when cloning from a standby
This commit is contained in:
60
repmgr.c
60
repmgr.c
@@ -1212,6 +1212,7 @@ do_standby_unregister(void)
|
||||
static void
|
||||
do_standby_clone(void)
|
||||
{
|
||||
PGconn *primary_conn = NULL;
|
||||
PGconn *upstream_conn;
|
||||
PGresult *res;
|
||||
|
||||
@@ -1286,6 +1287,23 @@ do_standby_clone(void)
|
||||
log_info(_("Successfully connected to upstream node. Current installation size is %s\n"),
|
||||
cluster_size);
|
||||
|
||||
/*
|
||||
* If the upstream node is a standby, try to connect to the primary too so we
|
||||
* can write an event record
|
||||
*/
|
||||
if (is_standby(upstream_conn))
|
||||
{
|
||||
if (strlen(options.cluster_name))
|
||||
{
|
||||
primary_conn = get_master_connection(upstream_conn, options.cluster_name,
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
primary_conn = upstream_conn;
|
||||
}
|
||||
|
||||
/*
|
||||
* If --recovery-min-apply-delay was passed, check that
|
||||
* we're connected to PostgreSQL 9.4 or later
|
||||
@@ -1934,29 +1952,33 @@ stop_backup:
|
||||
log_hint(_("for example : /etc/init.d/postgresql start\n"));
|
||||
}
|
||||
|
||||
/* Log the event */
|
||||
initPQExpBuffer(&event_details);
|
||||
/* Log the event - if we could connect to the primary */
|
||||
|
||||
/* Add details about relevant runtime options used */
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("Cloned from host '%s', port %s"),
|
||||
runtime_options.host,
|
||||
runtime_options.masterport);
|
||||
if (primary_conn != NULL)
|
||||
{
|
||||
initPQExpBuffer(&event_details);
|
||||
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("; backup method: %s"),
|
||||
runtime_options.rsync_only ? "rsync" : "pg_basebackup");
|
||||
/* Add details about relevant runtime options used */
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("Cloned from host '%s', port %s"),
|
||||
runtime_options.host,
|
||||
runtime_options.masterport);
|
||||
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("; --force: %s"),
|
||||
runtime_options.force ? "Y" : "N");
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("; backup method: %s"),
|
||||
runtime_options.rsync_only ? "rsync" : "pg_basebackup");
|
||||
|
||||
create_event_record(upstream_conn,
|
||||
&options,
|
||||
options.node,
|
||||
"standby_clone",
|
||||
true,
|
||||
event_details.data);
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("; --force: %s"),
|
||||
runtime_options.force ? "Y" : "N");
|
||||
|
||||
create_event_record(primary_conn,
|
||||
&options,
|
||||
options.node,
|
||||
"standby_clone",
|
||||
true,
|
||||
event_details.data);
|
||||
}
|
||||
|
||||
PQfinish(upstream_conn);
|
||||
exit(retval);
|
||||
|
||||
Reference in New Issue
Block a user