diff --git a/repmgrd.c b/repmgrd.c index 30c95ff9..9cbca7db 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -2301,93 +2301,6 @@ parse_node_type(const char *type) } -static bool -update_node_record_set_master(PGconn *conn, int this_node_id, int old_master_node_id) -{ - PGresult *res; - char sqlquery[QUERY_STR_LEN]; - - log_debug(_("Setting failed node %i inactive; marking node %i as master\n"), old_master_node_id, this_node_id); - - res = PQexec(conn, "BEGIN"); - - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - log_err(_("Unable to begin transaction: %s\n"), - PQerrorMessage(conn)); - - PQclear(res); - return false; - } - - PQclear(res); - - sqlquery_snprintf(sqlquery, - " UPDATE %s.repl_nodes " - " SET active = FALSE " - " WHERE cluster = '%s' " - " AND id = %i ", - get_repmgr_schema_quoted(conn), - local_options.cluster_name, - old_master_node_id); - - res = PQexec(conn, sqlquery); - - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - log_err(_("Unable to set old master node %i as inactive: %s\n"), - old_master_node_id, - PQerrorMessage(conn)); - PQclear(res); - - PQexec(conn, "ROLLBACK"); - return false; - } - - PQclear(res); - - sqlquery_snprintf(sqlquery, - " UPDATE %s.repl_nodes " - " SET type = 'master', " - " upstream_node_id = NULL " - " WHERE cluster = '%s' " - " AND id = %i ", - get_repmgr_schema_quoted(conn), - local_options.cluster_name, - this_node_id); - - res = PQexec(conn, sqlquery); - - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - log_err(_("Unable to set current node %i as active master: %s\n"), - this_node_id, - PQerrorMessage(conn)); - PQclear(res); - - PQexec(conn, "ROLLBACK"); - return false; - } - - PQclear(res); - - res = PQexec(conn, "COMMIT"); - - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - log_err(_("Unable to set commit transaction: %s\n"), - PQerrorMessage(conn)); - PQclear(res); - - return false; - } - - PQclear(res); - - return true; -} - - static bool update_node_record_set_upstream(PGconn *conn, int this_node_id, int new_upstream_node_id) {