From d9d60fa4204f4da4b24b7c22ceb5578a75b99e61 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 10 May 2022 15:02:24 +0900 Subject: [PATCH] standby clone: don't error out if unable to determine cluster size The cluster size check is purely informative, and is not in any way essential for the standby clone operation. As it's possible the query may fail if the repmgr user does not have sufficient privileges to query all databases in the cluster, we can simply ignore any failure. Note that the code comment indicated the query also served to sanity- check that queries can actually be executed. While this was the case historically, the preceding server version check now serves the same purpose and will not have the same risk of failure due to missing permissions. --- HISTORY | 1 + dbutils.c | 7 +------ doc/appendix-release-notes.xml | 27 ++++++++++++++++++++++++++- repmgr-action-standby.c | 16 +++++++--------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/HISTORY b/HISTORY index 5f8dcde9..4491b44d 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,6 @@ 5.3.1 2022-??-?? repmgrd: fixes for potential connection leaks (hslightdb) + standby clone: don't error out if unable to determine cluster size (Ian) 5.3.0 2021-10-12 standby switchover: improve handling of node rejoin failure (Ian) diff --git a/dbutils.c b/dbutils.c index 4806c497..0275bbde 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1291,21 +1291,16 @@ get_cluster_size(PGconn *conn, char *size) initPQExpBuffer(&query); appendPQExpBufferStr(&query, "SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) " - " FROM pg_catalog.pg_database "); + " FROM pg_catalog.pg_database "); log_verbose(LOG_DEBUG, "get_cluster_size():\n%s", query.data); res = PQexec(conn, query.data); if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_db_error(conn, query.data, _("get_cluster_size(): unable to execute query")); success = false; - } else - { snprintf(size, MAXLEN, "%s", PQgetvalue(res, 0, 0)); - } termPQExpBuffer(&query); PQclear(res); diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index fdb18272..dd72eb55 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -14,10 +14,35 @@ See also: + + Release 5.3.2 + ??? ??? ???, 2022 + + &repmgr; 5.3.2 is a minor release. + + + Bug fixes + + + + + repmgr standby clone: + don't treat inability to determine the cluster size as a fatal error. + + + The cluster size is displayed for informational purposes and is not essential + for execution of the clone operation. As the &repmgr; user may not have permissions + for all databases in the cluster, ignore the cluster size query if it fails. + + + + + + - Release 5.3.1 + Release 5.3.1 Tue 15 February, 2022 &repmgr; 5.3.1 is a minor release. diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 6e10f152..ec0031f8 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -5783,20 +5783,18 @@ check_source_server() } /* - * If a connection was established, perform some sanity checks on the - * provided upstream connection. + * The server version check will also serve as a sanity-check that we can + * actually execute queries on this connection. */ - source_server_version_num = check_server_version(source_conn, "primary", true, NULL); /* - * It's not essential to know the cluster size, but useful to sanity-check - * we can actually run a query before going any further. + * The cluster size is nice to have, but not essential to know, so only display + * something if the user has sufficient permissions to retrieve the size of + * all databases. */ - if (get_cluster_size(source_conn, cluster_size) == false) - exit(ERR_DB_QUERY); - - log_detail(_("current installation size is %s"), + if (get_cluster_size(source_conn, cluster_size) == true) + log_detail(_("current installation size is %s"), cluster_size); /*