[bitnami/postgresql] Issue 77295 Enable native recovery with flag/env var (#77502)

* [bitnami/postgresql] Adds feature flag for pg native recovery

Signed-off-by: Marco Fuchs <mfuchs135@gmail.com>
Signed-off-by: FuxMak <mfuchs135@gmail.com>

* [bitnami/postgresql] Adds new recovery flag to readme

Signed-off-by: Marco Fuchs <mfuchs135@gmail.com>
Signed-off-by: FuxMak <mfuchs135@gmail.com>

* [bitnami/postgresql] Improves robustness of feature flag logic with is_boolean_yes function

Signed-off-by: Marco Fuchs <mfuchs135@gmail.com>
Signed-off-by: FuxMak <mfuchs135@gmail.com>

---------

Signed-off-by: Marco Fuchs <mfuchs135@gmail.com>
Signed-off-by: FuxMak <mfuchs135@gmail.com>
This commit is contained in:
Marco Fuchs
2025-03-12 12:14:54 +01:00
committed by GitHub
parent 59a77c034d
commit c50bf1d7df
3 changed files with 17 additions and 7 deletions

View File

@@ -569,12 +569,17 @@ postgresql_is_file_external() {
# None
#########################
postgresql_clean_from_restart() {
local -r -a files=(
local -a files=(
"$POSTGRESQL_DATA_DIR"/postmaster.pid
"$POSTGRESQL_DATA_DIR"/standby.signal
"$POSTGRESQL_DATA_DIR"/recovery.signal
)
# Enable recovery only when POSTGRESQL_PERFORM_RESTORE feature flag is set
if ! is_boolean_yes "$POSTGRESQL_PERFORM_RESTORE" ; then
files+=("$POSTGRESQL_DATA_DIR"/recovery.signal)
fi
for file in "${files[@]}"; do
if [[ -f "$file" ]]; then
info "Cleaning stale $file file"

View File

@@ -99,6 +99,7 @@ postgresql_env_vars=(
POSTGRESQL_AUTOCTL_MODE
POSTGRESQL_AUTOCTL_MONITOR_HOST
POSTGRESQL_AUTOCTL_HOSTNAME
POSTGRESQL_PERFORM_RESTORE
POSTGRES_DATA_DIR
PGDATA
POSTGRES_SHUTDOWN_MODE
@@ -336,6 +337,9 @@ export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}"
export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}"
export POSTGRESQL_USE_CUSTOM_PGHBA_INITIALIZATION="no"
# Native recovery settings
export POSTGRESQL_PERFORM_RESTORE="${POSTGRESQL_PERFORM_RESTORE:-false}"
# pgAutoFailover settings
export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl"
export POSTGRESQL_AUTOCTL_CONF_DIR="${POSTGRESQL_AUTOCTL_CONF_DIR:-${POSTGRESQL_AUTOCTL_VOLUME_DIR}/.config}"

View File

@@ -173,7 +173,7 @@ docker-compose up -d
#### Customizable environment variables
| Name | Description | Default Value |
|--------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------------|
| ------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| `POSTGRESQL_VOLUME_DIR` | Persistence base directory | `/bitnami/postgresql` |
| `POSTGRESQL_DATA_DIR` | PostgreSQL data directory | `${POSTGRESQL_VOLUME_DIR}/data` |
| `POSTGRESQL_EXTRA_FLAGS` | Extra flags for PostgreSQL initialization | `nil` |
@@ -249,11 +249,12 @@ docker-compose up -d
| `POSTGRESQL_AUTOCTL_MODE` | pgAutoFailover node type, valid values [monitor, postgres] | `postgres` |
| `POSTGRESQL_AUTOCTL_MONITOR_HOST` | Hostname for the monitor component | `monitor` |
| `POSTGRESQL_AUTOCTL_HOSTNAME` | Hostname by which postgres is reachable | `$(hostname --fqdn)` |
| `POSTGRESQL_PERFORM_RESTORE` | Flag to skip deletion of `recovery.signal` file to enable native recovery. e.g by using `wal-g` | `false` |
#### Read-only environment variables
| Name | Description | Value |
|----------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------|
| -------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------- |
| `POSTGRESQL_BASE_DIR` | PostgreSQL installation directory | `/opt/bitnami/postgresql` |
| `POSTGRESQL_DEFAULT_CONF_DIR` | PostgreSQL configuration directory | `$POSTGRESQL_BASE_DIR/conf.default` |
| `POSTGRESQL_CONF_DIR` | PostgreSQL configuration directory | `$POSTGRESQL_BASE_DIR/conf` |
@@ -575,7 +576,7 @@ postgres=# select application_name as server, state,
postgres-# sync_priority as priority, sync_state
postgres-# from pg_stat_replication;
| server | state | priority | sync_state |
|-------------|-----------|----------|------------|
| ----------- | --------- | -------- | ---------- |
| walreceiver | streaming | 0 | sync |
| walreceiver | streaming | 0 | async |
```
@@ -803,7 +804,7 @@ docker build --build-arg EXTRA_LOCALES="es_ES.UTF-8 UTF-8" ...
The Bitnami PostgreSQL container allows two different sets of environment variables. Please see the list of environment variable aliases in the next table:
| Environment Variable | Alias |
|:-------------------------------------|:-----------------------------------|
| :----------------------------------- | :--------------------------------- |
| POSTGRESQL_USERNAME | POSTGRES_USER |
| POSTGRESQL_DATABASE | POSTGRES_DB |
| POSTGRESQL_PASSWORD | POSTGRES_PASSWORD |
@@ -834,7 +835,7 @@ alter database POSTGRES_DATABASE owner to POSTGRES_USER;
It is possible to change the user that PostgreSQL will use to execute the init scripts. To do so, use the following environment variables:
| Environment variable | Description |
|---------------------------------|-------------------------------------------------------------------|
| ------------------------------- | ----------------------------------------------------------------- |
| POSTGRESQL_INITSCRIPTS_USERNAME | User that will be used to execute the init scripts |
| POSTGRESQL_INITSCRIPTS_PASSWORD | Password for the user specified in POSTGRESQL_INITSCRIPT_USERNAME |