From 3581fa35f1fec0b228cce8a42cbcd0062ed0e752 Mon Sep 17 00:00:00 2001 From: Florian Kamella Date: Fri, 8 Sep 2023 14:51:09 +0200 Subject: [PATCH 1/2] Introduce environment variable POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION (#25013) Signed-off-by: Florian Kamella --- .../rootfs/opt/bitnami/scripts/postgresql/run.sh | 4 ++++ .../rootfs/opt/bitnami/scripts/postgresql/run.sh | 4 ++++ .../rootfs/opt/bitnami/scripts/postgresql/run.sh | 4 ++++ .../rootfs/opt/bitnami/scripts/postgresql/run.sh | 4 ++++ .../rootfs/opt/bitnami/scripts/postgresql/run.sh | 4 ++++ bitnami/postgresql/README.md | 8 ++++++++ 6 files changed, 28 insertions(+) diff --git a/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh b/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh index 249e9082e5388..3273b4adf3883 100755 --- a/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh +++ b/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh @@ -23,6 +23,10 @@ if [[ -n "${POSTGRESQL_EXTRA_FLAGS:-}" ]]; then flags+=("${extra_flags[@]}") fi +if [[ -n "${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" ]]; then + flags+=("-c" "default_transaction_isolation=$POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION") +fi + flags+=("$@") cmd=$(command -v postgres) diff --git a/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh b/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh index 249e9082e5388..3273b4adf3883 100755 --- a/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh +++ b/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh @@ -23,6 +23,10 @@ if [[ -n "${POSTGRESQL_EXTRA_FLAGS:-}" ]]; then flags+=("${extra_flags[@]}") fi +if [[ -n "${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" ]]; then + flags+=("-c" "default_transaction_isolation=$POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION") +fi + flags+=("$@") cmd=$(command -v postgres) diff --git a/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh b/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh index 249e9082e5388..3273b4adf3883 100755 --- a/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh +++ b/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh @@ -23,6 +23,10 @@ if [[ -n "${POSTGRESQL_EXTRA_FLAGS:-}" ]]; then flags+=("${extra_flags[@]}") fi +if [[ -n "${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" ]]; then + flags+=("-c" "default_transaction_isolation=$POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION") +fi + flags+=("$@") cmd=$(command -v postgres) diff --git a/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh b/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh index 249e9082e5388..3273b4adf3883 100755 --- a/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh +++ b/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh @@ -23,6 +23,10 @@ if [[ -n "${POSTGRESQL_EXTRA_FLAGS:-}" ]]; then flags+=("${extra_flags[@]}") fi +if [[ -n "${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" ]]; then + flags+=("-c" "default_transaction_isolation=$POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION") +fi + flags+=("$@") cmd=$(command -v postgres) diff --git a/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh b/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh index 249e9082e5388..3273b4adf3883 100755 --- a/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh +++ b/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql/run.sh @@ -23,6 +23,10 @@ if [[ -n "${POSTGRESQL_EXTRA_FLAGS:-}" ]]; then flags+=("${extra_flags[@]}") fi +if [[ -n "${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" ]]; then + flags+=("-c" "default_transaction_isolation=$POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION") +fi + flags+=("$@") cmd=$(command -v postgres) diff --git a/bitnami/postgresql/README.md b/bitnami/postgresql/README.md index d8ce515307ab1..7ff4dc35a0fce 100644 --- a/bitnami/postgresql/README.md +++ b/bitnami/postgresql/README.md @@ -181,6 +181,14 @@ Passing extra command-line flags to the postgresql service command is possible t * `POSTGRESQL_EXTRA_FLAGS`: Flags to be appended to the `postgres` startup command. No defaults +#### Adjusting the default transaction isolation level + +The default transaction isolation level in postgresql is `read committed`, the global default transaction isolation level can be changed using the environment variable `POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION`. + +Possible values are: `read uncommitted`, `read committed`, `repeatable read` or `serializable`. For more details consult the documentation for `default_transaction_isolation` in + +*Note: Setting `default_transaction_isolation` via `POSTGRESQL_EXTRA_FLAGS` is currently only possible for transaction levels without white spaces in its name.* + ### Initializing a new instance When the container is executed for the first time, it will execute the files with extensions `.sh`, `.sql` and `.sql.gz` located at `/docker-entrypoint-initdb.d`. From df9866a0aca4c295ef7ecbff5a345458022eae0e Mon Sep 17 00:00:00 2001 From: Florian Kamella Date: Thu, 14 Sep 2023 11:48:03 +0200 Subject: [PATCH 2/2] fixup: add new environment variable to postgresql-env.sh Signed-off-by: Florian Kamella --- .../11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../15/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ 5 files changed, 10 insertions(+) diff --git a/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index d35ec5a62e51d..e4fa8f5255345 100644 --- a/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -92,6 +92,7 @@ postgresql_env_vars=( POSTGRESQL_WAL_LEVEL POSTGRESQL_DEFAULT_TOAST_COMPRESSION POSTGRESQL_PASSWORD_ENCRYPTION + POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION POSTGRESQL_AUTOCTL_CONF_DIR POSTGRESQL_AUTOCTL_MODE POSTGRESQL_AUTOCTL_MONITOR_HOST @@ -327,6 +328,7 @@ export POSTGRESQL_POSTGRES_CONNECTION_LIMIT="${POSTGRESQL_POSTGRES_CONNECTION_LI export POSTGRESQL_WAL_LEVEL="${POSTGRESQL_WAL_LEVEL:-replica}" export POSTGRESQL_DEFAULT_TOAST_COMPRESSION="${POSTGRESQL_DEFAULT_TOAST_COMPRESSION:-}" export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}" +export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" # pgAutoFailover settings export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl" diff --git a/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index d35ec5a62e51d..e4fa8f5255345 100644 --- a/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -92,6 +92,7 @@ postgresql_env_vars=( POSTGRESQL_WAL_LEVEL POSTGRESQL_DEFAULT_TOAST_COMPRESSION POSTGRESQL_PASSWORD_ENCRYPTION + POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION POSTGRESQL_AUTOCTL_CONF_DIR POSTGRESQL_AUTOCTL_MODE POSTGRESQL_AUTOCTL_MONITOR_HOST @@ -327,6 +328,7 @@ export POSTGRESQL_POSTGRES_CONNECTION_LIMIT="${POSTGRESQL_POSTGRES_CONNECTION_LI export POSTGRESQL_WAL_LEVEL="${POSTGRESQL_WAL_LEVEL:-replica}" export POSTGRESQL_DEFAULT_TOAST_COMPRESSION="${POSTGRESQL_DEFAULT_TOAST_COMPRESSION:-}" export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}" +export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" # pgAutoFailover settings export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl" diff --git a/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index d35ec5a62e51d..e4fa8f5255345 100644 --- a/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -92,6 +92,7 @@ postgresql_env_vars=( POSTGRESQL_WAL_LEVEL POSTGRESQL_DEFAULT_TOAST_COMPRESSION POSTGRESQL_PASSWORD_ENCRYPTION + POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION POSTGRESQL_AUTOCTL_CONF_DIR POSTGRESQL_AUTOCTL_MODE POSTGRESQL_AUTOCTL_MONITOR_HOST @@ -327,6 +328,7 @@ export POSTGRESQL_POSTGRES_CONNECTION_LIMIT="${POSTGRESQL_POSTGRES_CONNECTION_LI export POSTGRESQL_WAL_LEVEL="${POSTGRESQL_WAL_LEVEL:-replica}" export POSTGRESQL_DEFAULT_TOAST_COMPRESSION="${POSTGRESQL_DEFAULT_TOAST_COMPRESSION:-}" export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}" +export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" # pgAutoFailover settings export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl" diff --git a/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index d35ec5a62e51d..e4fa8f5255345 100644 --- a/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -92,6 +92,7 @@ postgresql_env_vars=( POSTGRESQL_WAL_LEVEL POSTGRESQL_DEFAULT_TOAST_COMPRESSION POSTGRESQL_PASSWORD_ENCRYPTION + POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION POSTGRESQL_AUTOCTL_CONF_DIR POSTGRESQL_AUTOCTL_MODE POSTGRESQL_AUTOCTL_MONITOR_HOST @@ -327,6 +328,7 @@ export POSTGRESQL_POSTGRES_CONNECTION_LIMIT="${POSTGRESQL_POSTGRES_CONNECTION_LI export POSTGRESQL_WAL_LEVEL="${POSTGRESQL_WAL_LEVEL:-replica}" export POSTGRESQL_DEFAULT_TOAST_COMPRESSION="${POSTGRESQL_DEFAULT_TOAST_COMPRESSION:-}" export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}" +export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" # pgAutoFailover settings export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl" diff --git a/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index d35ec5a62e51d..e4fa8f5255345 100644 --- a/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql/15/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -92,6 +92,7 @@ postgresql_env_vars=( POSTGRESQL_WAL_LEVEL POSTGRESQL_DEFAULT_TOAST_COMPRESSION POSTGRESQL_PASSWORD_ENCRYPTION + POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION POSTGRESQL_AUTOCTL_CONF_DIR POSTGRESQL_AUTOCTL_MODE POSTGRESQL_AUTOCTL_MONITOR_HOST @@ -327,6 +328,7 @@ export POSTGRESQL_POSTGRES_CONNECTION_LIMIT="${POSTGRESQL_POSTGRES_CONNECTION_LI export POSTGRESQL_WAL_LEVEL="${POSTGRESQL_WAL_LEVEL:-replica}" export POSTGRESQL_DEFAULT_TOAST_COMPRESSION="${POSTGRESQL_DEFAULT_TOAST_COMPRESSION:-}" export POSTGRESQL_PASSWORD_ENCRYPTION="${POSTGRESQL_PASSWORD_ENCRYPTION:-}" +export POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION="${POSTGRESQL_DEFAULT_TRANSACTION_ISOLATION:-}" # pgAutoFailover settings export POSTGRESQL_AUTOCTL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR}/pgautoctl"