mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
When following a new primary, have repmgr (not repmgrd) create the new slot
This commit is contained in:
34
repmgr.c
34
repmgr.c
@@ -582,6 +582,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
maxlen_snprintf(repmgr_slot_name, "repmgr_slot_%i", options.node);
|
||||
repmgr_slot_name_ptr = repmgr_slot_name;
|
||||
log_verbose(LOG_DEBUG, "slot name initialised as: %s\n", repmgr_slot_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -2031,6 +2032,39 @@ do_standby_follow(void)
|
||||
strncpy(runtime_options.masterport, PQport(master_conn), MAXLEN);
|
||||
strncpy(runtime_options.username, PQuser(master_conn), MAXLEN);
|
||||
|
||||
/*
|
||||
* If 9.4 or later, and replication slots in use, we'll need to create a
|
||||
* slot on the new master
|
||||
*/
|
||||
|
||||
if (options.use_replication_slots)
|
||||
{
|
||||
if (create_replication_slot(master_conn, repmgr_slot_name) == false)
|
||||
{
|
||||
PQExpBufferData event_details;
|
||||
initPQExpBuffer(&event_details);
|
||||
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("Unable to create slot '%s' on the master node: %s"),
|
||||
repmgr_slot_name,
|
||||
PQerrorMessage(master_conn));
|
||||
|
||||
log_err("%s\n", event_details.data);
|
||||
|
||||
create_event_record(master_conn,
|
||||
&options,
|
||||
options.node,
|
||||
"repmgr_follow",
|
||||
false,
|
||||
event_details.data);
|
||||
|
||||
PQfinish(conn);
|
||||
PQfinish(master_conn);
|
||||
exit(ERR_DB_QUERY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log_info(_("changing standby's master\n"));
|
||||
|
||||
/* Get the data directory full path */
|
||||
|
||||
29
repmgrd.c
29
repmgrd.c
@@ -1521,35 +1521,6 @@ do_master_failover(void)
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
/*
|
||||
* If 9.4 or later, and replication slots in use, we'll need to create a
|
||||
* slot on the new master
|
||||
*/
|
||||
new_master_conn = establish_db_connection(best_candidate.conninfo_str, true);
|
||||
|
||||
if (local_options.use_replication_slots)
|
||||
{
|
||||
if (create_replication_slot(new_master_conn, node_info.slot_name) == false)
|
||||
{
|
||||
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("Unable to create slot '%s' on the master node: %s"),
|
||||
node_info.slot_name,
|
||||
PQerrorMessage(new_master_conn));
|
||||
|
||||
log_err("%s\n", event_details.data);
|
||||
|
||||
create_event_record(new_master_conn,
|
||||
&local_options,
|
||||
node_info.node_id,
|
||||
"repmgrd_failover_follow",
|
||||
false,
|
||||
event_details.data);
|
||||
|
||||
PQfinish(new_master_conn);
|
||||
terminate(ERR_DB_QUERY);
|
||||
}
|
||||
}
|
||||
|
||||
log_debug(_("executing follow command: \"%s\"\n"), local_options.follow_command);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user