Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kondo-dc opened this issue Apr 17, 2024 · 2 comments
Open

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

kondo-dc opened this issue Apr 17, 2024 · 2 comments

Comments

@kondo-dc
Copy link

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
@achernyakevich-sc
Copy link

I agree that correct setting of transaction isolation should be presented out of the box and asked earlier. See more in the #303 and related comment.

@kondo-dc
Copy link
Author

Thanks for your advice.

I am building my own environment on AWS and using RDS.
I don't configure the DB in docker-compose.yml, so it would be easier if I could configure it in the redmine container.

If this issue is not supported, I would like to change my RDS configuration or continue with my current solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants