From 80fd89cdb46bb5baaf70ddd0dea6800ec5cd5969 Mon Sep 17 00:00:00 2001 From: Bitnami Bot Date: Wed, 16 Oct 2019 04:04:16 +0000 Subject: [PATCH] 9.6.15-centos-7-r75 release --- bitnami/postgresql/9.6/centos-7/Dockerfile | 4 +- .../9.6/centos-7/rootfs/libpostgresql.sh | 52 +++++++++++++++---- bitnami/postgresql/README.md | 2 +- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/bitnami/postgresql/9.6/centos-7/Dockerfile b/bitnami/postgresql/9.6/centos-7/Dockerfile index 2e557f11ab97..93c4113f4267 100644 --- a/bitnami/postgresql/9.6/centos-7/Dockerfile +++ b/bitnami/postgresql/9.6/centos-7/Dockerfile @@ -1,4 +1,4 @@ -FROM bitnami/centos-extras-base:7-r172 +FROM bitnami/centos-extras-base:7-r173 LABEL maintainer "Bitnami " ENV BITNAMI_PKG_CHMOD="-R g+rwX" \ @@ -15,7 +15,7 @@ COPY rootfs / RUN yum --enablerepo base,updates,extras -y install epel-release && yum --enablerepo base,updates,extras -y update && yum --enablerepo base,updates -y install nss_wrapper RUN /postunpack.sh ENV BITNAMI_APP_NAME="postgresql" \ - BITNAMI_IMAGE_VERSION="9.6.15-centos-7-r74" \ + BITNAMI_IMAGE_VERSION="9.6.15-centos-7-r75" \ LANG="en_US.UTF-8" \ LANGUAGE="en_US:en" \ NAMI_PREFIX="/.nami" \ diff --git a/bitnami/postgresql/9.6/centos-7/rootfs/libpostgresql.sh b/bitnami/postgresql/9.6/centos-7/rootfs/libpostgresql.sh index 16ac9a94344a..e2205057aad9 100644 --- a/bitnami/postgresql/9.6/centos-7/rootfs/libpostgresql.sh +++ b/bitnami/postgresql/9.6/centos-7/rootfs/libpostgresql.sh @@ -138,6 +138,11 @@ export POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-}" export POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-on}" export POSTGRESQL_FSYNC="${POSTGRESQL_FSYNC:-on}" export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-postgres}" + +# Version +export POSTGRESQL_VERSION="$(echo "$BITNAMI_IMAGE_VERSION" | grep -oP "^\d+\.\d+\.\d+")" +export POSTGRESQL_MAJOR_VERSION="$(echo "$BITNAMI_IMAGE_VERSION" | grep -oP "^\d+")" + EOF if [[ -f "${POSTGRESQL_PASSWORD_FILE:-}" ]]; then cat <<"EOF" @@ -474,6 +479,30 @@ postgresql_is_file_external() { fi } +######################## +# Remove flags and postmaster files from a previous run (case of container restart) +# Globals: +# POSTGRESQL_* +# Arguments: +# None +# Returns: +# None +######################### +postgresql_clean_from_restart() { + local -r -a files=( + "$POSTGRESQL_DATA_DIR"/postmaster.pid + "$POSTGRESQL_DATA_DIR"/standby.signal + "$POSTGRESQL_DATA_DIR"/recovery.signal + ) + + for file in "${files[@]}"; do + if [[ -f "$file" ]]; then + postgresql_info "Cleaning stale $file file" + rm "$file" + fi + done +} + ######################## # Ensure PostgreSQL is initialized # Globals: @@ -485,7 +514,7 @@ postgresql_is_file_external() { ######################### postgresql_initialize() { postgresql_info "Initializing PostgreSQL database..." - + postgresql_clean_from_restart # This fixes an issue where the trap would kill the entrypoint.sh, if a PID was left over from a previous run # Exec replaces the process without creating a new one, and when the container is restarted it may have the same PID rm -f "$POSTGRESQL_PID_FILE" @@ -518,11 +547,6 @@ postgresql_initialize() { if ! is_dir_empty "$POSTGRESQL_DATA_DIR"; then postgresql_info "Deploying PostgreSQL with persisted data..." - local -r postmaster_path="$POSTGRESQL_DATA_DIR"/postmaster.pid - if [[ -f "$postmaster_path" ]]; then - postgresql_info "Cleaning stale postmaster.pid file" - rm "$postmaster_path" - fi is_boolean_yes "$create_pghba_file" && postgresql_restrict_pghba is_boolean_yes "$create_conf_file" && postgresql_configure_replication_parameters is_boolean_yes "$create_conf_file" && postgresql_configure_fsync @@ -800,9 +824,15 @@ postgresql_slave_init_db() { ######################### postgresql_configure_recovery() { postgresql_info "Setting up streaming replication slave..." - cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE" - chmod 600 "$POSTGRESQL_RECOVERY_FILE" - postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE" - postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${POSTGRESQL_REPLICATION_PASSWORD} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE" - postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE" + if (( POSTGRESQL_MAJOR_VERSION >= 12 )); then + postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${POSTGRESQL_REPLICATION_PASSWORD} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE" + postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE" + touch "$POSTGRESQL_DATA_DIR"/standby.signal + else + cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE" + chmod 600 "$POSTGRESQL_RECOVERY_FILE" + postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE" + postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${POSTGRESQL_REPLICATION_PASSWORD} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE" + postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE" + fi } diff --git a/bitnami/postgresql/README.md b/bitnami/postgresql/README.md index 9e889e527923..8b61ed75979c 100644 --- a/bitnami/postgresql/README.md +++ b/bitnami/postgresql/README.md @@ -55,7 +55,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t * [`10-centos-7`, `10.10.0-centos-7-r75` (10/centos-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/10.10.0-centos-7-r75/10/centos-7/Dockerfile) * [`9.6-ol-7`, `9.6.15-ol-7-r76` (9.6/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.15-ol-7-r76/9.6/ol-7/Dockerfile) * [`9.6-debian-9`, `9.6.15-debian-9-r70`, `9.6`, `9.6.15`, `9.6.15-r70` (9.6/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.15-debian-9-r70/9.6/debian-9/Dockerfile) -* [`9.6-centos-7`, `9.6.15-centos-7-r74` (9.6/centos-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.15-centos-7-r74/9.6/centos-7/Dockerfile) +* [`9.6-centos-7`, `9.6.15-centos-7-r75` (9.6/centos-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.15-centos-7-r75/9.6/centos-7/Dockerfile) Subscribe to project updates by watching the [bitnami/postgresql GitHub repo](https://github.com/bitnami/bitnami-docker-postgresql).