From e9c2d741eea4faa95caaea11633bc44ca6cc1e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20R=C3=ADos=20Saavedra?= Date: Thu, 17 Feb 2022 16:36:56 +0100 Subject: [PATCH] [bitnami/postgresql-ha] Mitigate brain split situations (#9035) * [bitnami/postgresql-ha] Mitigate brain split situations Signed-off-by: Rafael Rios Saavedra * [bitnami/postgresql-ha] Mitigate brain split situations Signed-off-by: Rafael Rios Saavedra --- bitnami/postgresql-ha/Chart.yaml | 2 +- bitnami/postgresql-ha/README.md | 4 ++-- .../postgresql/hooks-scripts-configmap.yaml | 12 ++++++------ bitnami/postgresql-ha/values.yaml | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bitnami/postgresql-ha/Chart.yaml b/bitnami/postgresql-ha/Chart.yaml index f25d47487..03583cd62 100644 --- a/bitnami/postgresql-ha/Chart.yaml +++ b/bitnami/postgresql-ha/Chart.yaml @@ -27,4 +27,4 @@ name: postgresql-ha sources: - https://github.com/bitnami/bitnami-docker-postgresql - https://www.postgresql.org/ -version: 8.3.2 +version: 8.4.0 diff --git a/bitnami/postgresql-ha/README.md b/bitnami/postgresql-ha/README.md index db9f8f345..ab79cd04a 100644 --- a/bitnami/postgresql-ha/README.md +++ b/bitnami/postgresql-ha/README.md @@ -173,8 +173,8 @@ Additionally, if `persistence.resourcePolicy` is set to `keep`, you should manua | `postgresql.repmgrDatabase` | PostgreSQL Repmgr database | `repmgr` | | `postgresql.repmgrLogLevel` | Repmgr log level (DEBUG, INFO, NOTICE, WARNING, ERROR, ALERT, CRIT or EMERG) | `NOTICE` | | `postgresql.repmgrConnectTimeout` | Repmgr backend connection timeout (in seconds) | `5` | -| `postgresql.repmgrReconnectAttempts` | Repmgr backend reconnection attempts | `3` | -| `postgresql.repmgrReconnectInterval` | Repmgr backend reconnection interval (in seconds) | `5` | +| `postgresql.repmgrReconnectAttempts` | Repmgr backend reconnection attempts | `2` | +| `postgresql.repmgrReconnectInterval` | Repmgr backend reconnection interval (in seconds) | `3` | | `postgresql.usePgRewind` | Use pg_rewind for standby failover (experimental) | `false` | | `postgresql.audit.logHostname` | Add client hostnames to the log file | `true` | | `postgresql.audit.logConnections` | Add client log-in operations to the log file | `false` | diff --git a/bitnami/postgresql-ha/templates/postgresql/hooks-scripts-configmap.yaml b/bitnami/postgresql-ha/templates/postgresql/hooks-scripts-configmap.yaml index c717af16a..189691b23 100644 --- a/bitnami/postgresql-ha/templates/postgresql/hooks-scripts-configmap.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/hooks-scripts-configmap.yaml @@ -26,6 +26,9 @@ data: . /opt/bitnami/scripts/libpostgresql.sh . /opt/bitnami/scripts/librepmgr.sh + # Load PostgreSQL & repmgr environment variables + . /opt/bitnami/scripts/postgresql-env.sh + # Auxiliary functions is_new_primary_ready() { return_value=1 @@ -52,19 +55,16 @@ data: exec 2>/dev/null fi - # Load PostgreSQL & repmgr environment variables - . /opt/bitnami/scripts/postgresql-env.sh - postgresql_enable_nss_wrapper # Prepare env vars for managing roles - primary_node="$(repmgr_get_primary_node)" - primary_host="$(echo $primary_node | awk '{print $1}')" + readarray -t primary_node < <(repmgr_get_upstream_node) + primary_host="${primary_node[0]}" # Stop postgresql for graceful exit. postgresql_stop - if [[ "$primary_host" == "$REPMGR_NODE_NETWORK_NAME" ]]; then + if [[ -z "$primary_host" ]] || [[ "$primary_host" == "$REPMGR_NODE_NETWORK_NAME" ]]; then info "Primary node need to wait for a new primary node before leaving the cluster" retry_while is_new_primary_ready 10 5 else diff --git a/bitnami/postgresql-ha/values.yaml b/bitnami/postgresql-ha/values.yaml index 7eb26c3ac..252dd6a97 100644 --- a/bitnami/postgresql-ha/values.yaml +++ b/bitnami/postgresql-ha/values.yaml @@ -398,8 +398,8 @@ postgresql: repmgrDatabase: repmgr repmgrLogLevel: NOTICE repmgrConnectTimeout: 5 - repmgrReconnectAttempts: 3 - repmgrReconnectInterval: 5 + repmgrReconnectAttempts: 2 + repmgrReconnectInterval: 3 ## EXPERMENTAL: Use pg_rewind for standby failover ## @param postgresql.usePgRewind Use pg_rewind for standby failover (experimental) ##