From 3581fa35f1fec0b228cce8a42cbcd0062ed0e752 Mon Sep 17 00:00:00 2001 From: Florian Kamella Date: Fri, 8 Sep 2023 14:51:09 +0200 Subject: [PATCH] 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`.