← Back to Pull requests

Add comment and warning for MySQL repeatable read #518

Open
mgaffigan opened this pull request with 61 lines diff across 5 files
View on GitHub
mgaffigan mgaffigan commented on Oct 26, 2026 20:45 UTC
Author

Running MySQL at the default REPEATABLE_READ transaction isolation level causes hangs and errors throughout the application when running at load. These were frequently the cause of flaky tests in #449, and have issues open in the nextgen repo.

Add a warning to startup to check for misconfigured instances, and update the instructions in mirth.properties to have the correct transaction isolation level.

Release note:

MySQL installs should not run at REPEATABLE READ. The server will now warn if you run at REPEATABLE READ, and will block new installs at REPEATABLE READ. Update your connection string per the guidance in mirth.properties.

Diff: 61 lines (+59 / -2) across 5 files Reviewer: NicoPiel Review duration: 25871m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.34) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.34 · 61 lines diff across 5 files
0.34
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.84 · 5 substantive comment(s)
0.84
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
88%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.247
Real PR Conversation Timeline
15 items
github-actions[bot] github-actions[bot] commented on Oct 26, 2026 20:56 UTC
Bot

Test Results


130 files  ±0  130 suites  ±0   4m 6s ⏱️ + 1m 4s
789 tests ±0  789 ✅ ±0  0 💤 ±0  0 ❌ ±0 
915 runs  ±0  909 ✅ ±0  6 💤 ±0  0 ❌ ±0 

Results for commit de18cb3c. ± Comparison against base commit a4030393.

[test-results]:data:application/gzip;base64,H4sIAD4b4moC/13MSw7CIBSF4a00jB3wEAQ3Y+ACCbEthsfIuHeplgYd/t9JzhP5MLuMrhNh+DShXEMZ0takS4hrA3oWDdpYtvkiVa9brgD/dA+PRvgAr8P8Ay6lmHZJdd0+FeF79EuF1SHfR9F7OPz0+AdxWUJpgawjEgwDqigjVgInxlgPzhAMXGLBqcYGpEOvN0g+R9wJAQAA

:recycle: This comment has been updated with latest results.

pacmano1 pacmano1 commented on Oct 26, 2026 21:31 UTC
Contributor

I would refuse to start. Like driving on a bald tire ( mandatory car ananlogy) and protect the user from themselves.

mgaffigan mgaffigan commented on Oct 26, 2026 21:48 UTC
Author

I would refuse to start. Like driving on a bald tire ( mandatory car ananlogy) and protect the user from themselves.

Sure - the less interrupting scenario here is that we could set the transaction isolation level ourselves, but such changes are highly affecting. If we include a "do it anyway", I could get on board with that.

I question making such a big change without the administrator being involved. Channels _could_ be relying upon repeatable read for correctness.

pacmano1 pacmano1 commented on Oct 26, 2026 21:54 UTC
Contributor

> I would refuse to start. Like driving on a bald tire ( mandatory car ananlogy) and protect the user from themselves.

> Sure - the less interrupting scenario here is that we could set the transaction isolation level ourselves, but such changes are highly affecting. If we include a "do it anyway", I could get on board with that.

> I question making such a big change without the administrator being involved. Channels _could_ be relying upon repeatable read for correctness.

maybe for fresh installs do a hard stop?

mgaffigan mgaffigan commented on Oct 26, 2026 23:07 UTC
Author

maybe for fresh installs do a hard stop?

That could work. Sure. Updated.

NicoPiel NicoPiel requested changes on Oct 27, 2026 10:59 UTC
Changes Requested Reviewer

The check doesn’t match its message. Both checks only reject REPEATABLE_READ, but the messages say READ-COMMITTED is required. SERIALIZABLE, which locks even more, gets through with no block and no warning. The fix is to test for “not READ_COMMITTED” instead.

mgaffigan mgaffigan commented on Oct 27, 2026 15:50 UTC
Author

The check doesn’t match its message. Both checks only reject REPEATABLE_READ, but the messages say READ-COMMITTED is required. SERIALIZABLE, which locks even more, gets through with no block and no warning. The fix is to test for “not READ_COMMITTED” instead.

This is intentional, but I'm open to other phrasing of the message.

A DBA may reasonably configure the system away from READ_COMMITTED - the problem is that the default for MySQL is REPEATABLE_READ, so people are unintentionally running with REPEATABLE_READ. There's not a reasonable way I've found to check that the transaction isolation level is configured away from the default explicitly - which leaves checking for the default.

tonygermano tonygermano commented on code on Oct 28, 2026 10:02 UTC
Code Review
donkey/src/main/java/com/mirth/connect/donkey/server/data/jdbc/MysqlDaoFactory.java:1
@@ -9,13 +9,53 @@
 
 package com.mirth.connect.donkey.server.data.jdbc;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.mirth.connect.donkey.server.data.DonkeyDaoException;
 import com.mirth.connect.donkey.util.SerializerProvider;
 
 public class MysqlDaoFactory extends JdbcDaoFactory {
+    private Logger logger = LogManager.getLogger(this.getClass());

    private static final Logger logger = LogManager.getLogger(this.getClass());

tonygermano tonygermano commented on code on Oct 28, 2026 10:03 UTC
Code Review
donkey/src/main/java/com/mirth/connect/donkey/server/data/jdbc/MysqlDaoFactory.java:1
@@ -9,13 +9,53 @@
 
 package com.mirth.connect.donkey.server.data.jdbc;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.mirth.connect.donkey.server.data.DonkeyDaoException;
 import com.mirth.connect.donkey.util.SerializerProvider;
 
 public class MysqlDaoFactory extends JdbcDaoFactory {
+    private Logger logger = LogManager.getLogger(this.getClass());
+    private boolean hasCheckedTransactionIsolation = false;

    private final AtomicBoolean hasCheckedTransactionIsolation = new AtomicBoolean(false);

tonygermano tonygermano commented on code on Oct 28, 2026 10:06 UTC
Code Review
donkey/src/main/java/com/mirth/connect/donkey/server/data/jdbc/MysqlDaoFactory.java:1
@@ -9,13 +9,53 @@
 
 package com.mirth.connect.donkey.server.data.jdbc;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.mirth.connect.donkey.server.data.DonkeyDaoException;
 import com.mirth.connect.donkey.util.SerializerProvider;
 
 public class MysqlDaoFactory extends JdbcDaoFactory {
+    private Logger logger = LogManager.getLogger(this.getClass());
+    private boolean hasCheckedTransactionIsolation = false;
+
     @Override
     public JdbcDao getDao(SerializerProvider serializerProvider) {
         JdbcDao dao = super.getDao(serializerProvider);
         dao.setQuoteChar('`');
+        checkTransactionIsolation(dao);
         return dao;
     }
+
+    @Override
+    public void checkNewDatabase(Connection connection) {
+        try {
+            if (connection.getTransactionIsolation() == Connection.TRANSACTION_REPEATABLE_READ) {
+                throw new DonkeyDaoException("Creating a new database with REPEATABLE-READ transaction " 
+                    + "isolation is not allowed.  Set the transaction isolation level in the database "
+                    + "URL or the database server to READ-COMMITTED.");
+            }
+        } catch (SQLException e) {
+            throw new DonkeyDaoException("Failed to check the transaction isolation level for this MySQL connection.", e);
+        }
+    }
+
+    /**
+     * Warns once if the connection is using the default REPEATABLE-READ transaction isolation level.
+     */
+    private void checkTransactionIsolation(JdbcDao dao) {
+        if (hasCheckedTransactionIsolation) return;
+        hasCheckedTransactionIsolation = true;

        if (!hasCheckedTransactionIsolation.compareAndSet(false, true)) {
            return;
        }

tonygermano tonygermano commented on Oct 28, 2026 10:17 UTC
Reviewer

A few minor things suggested inline, but, otherwise, looks good to me. Those were supposed to be part of the same review, but I guess I clicked the wrong button.

Could you also please create the release note and put it in the PR description?

mgaffigan mgaffigan commented on Oct 28, 2026 15:43 UTC
Author

@NicoPiel, I changed the phrasing of the message.

NicoPiel NicoPiel approved these changes on Oct 28, 2026 15:43 UTC
Approved Reviewer

Approved these changes.

gibson9583 gibson9583 approved these changes on Oct 30, 2026 10:48 UTC
Approved Reviewer

Looks safe to merge.

Reviewers
Assignees
mgaffigan mgaffigan
Labels
risk: low confidence: 88% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 33.6% (LOW) · Higher = larger blast radius
33.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 88% · Lower = rushed or shallow review
88%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4% · Safe to merge
4%