From 36bd7cdc9f9e089aee5cc4f1cae4ac06a73ae134 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 18 Oct 2018 17:26:29 +0900 Subject: [PATCH] Speed up witness "failover" during a switchover --- repmgr-action-standby.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index c517d2cb..a20f9443 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -4087,9 +4087,25 @@ do_standby_switchover(void) if (sibling_node_record.type == WITNESS) { + /* TODO: create "repmgr witness resync" or similar */ appendPQExpBuffer(&remote_command_str, "witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"", local_node_record.conninfo); + + /* + * Notify the witness repmgrd about the new primary, as at this point it will be assuming + * a failover situation is in place. It will detect the new primary at some point, this + * just speeds up the process. + * + * In the unlikely event repmgrd is not running or not in use, this will have no effect. + */ + cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo); + + if (PQstatus(cell->node_info->conn) == CONNECTION_OK) + { + notify_follow_primary(cell->node_info->conn, local_node_record.node_id); + } + PQfinish(cell->node_info->conn); } else {