Skip to content

Set transaction isolation level in config/database.yml #324

Description

@dc-kondo-kensuke

If you use MySQL and MariaDB with Redmine 5.1.1 or later, you need to set the transaction isolation level in config/database.yml.
For MySQL version 5.7.20 or older and MariaDB, the setting is tx_isolation instead of transaction_isolation.

https://www.redmine.org/projects/redmine/wiki/MySQL_configuration

So, It might be a good idea to edit docker-entrypoint.sh so that the transaction isolation level can be set in /config/database.yml.

The following is a temporary improvement in my environment.
Since I am using MariaDB, only "tx_isolation" is considered, but it should be possible to switch to "transaction_isolation".

diff --git a/5.1/bookworm/docker-entrypoint.sh b/5.1/bookworm/docker-entrypoint.sh
index ff3f94b..3390268 100755
--- a/5.1/bookworm/docker-entrypoint.sh
+++ b/5.1/bookworm/docker-entrypoint.sh
@@ -75,6 +75,7 @@ if [ -n "$isLikelyRedmine" ]; then
 			file_env 'REDMINE_DB_PASSWORD' "${MYSQL_ENV_MYSQL_PASSWORD:-${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
 			file_env 'REDMINE_DB_DATABASE' "${MYSQL_ENV_MYSQL_DATABASE:-${MYSQL_ENV_MYSQL_USER:-redmine}}"
 			file_env 'REDMINE_DB_ENCODING' ''
+			file_env 'REDMINE_DB_TX_ISOLATION' 'READ-COMMITTED'
 		elif [ "$REDMINE_DB_POSTGRES" ]; then
 			adapter='postgresql'
 			host="$REDMINE_DB_POSTGRES"
@@ -129,6 +130,10 @@ if [ -n "$isLikelyRedmine" ]; then
 			[ -n "$val" ] || continue
 			echo "  $var: \"$val\"" >> config/database.yml
 		done
+		if [ "$REDMINE_DB_TX_ISOLATION" ]; then
+			echo "  variables:" >> config/database.yml
+			echo "    tx_isolation: \"$REDMINE_DB_TX_ISOLATION\"" >> config/database.yml
+		fi
 	fi
 
 	# install additional gems for Gemfile.local and plugins

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions