Description
Describe the bug
In an environment using the AWS wrapper driver, we've encountered an intermittent error where calling setReadOnly
at the start or end of a transaction triggers the Aurora wrapper's topology, resulting in the error: "Cannot change transaction read-only property in the middle of a transaction."
Expected Behavior
If not strictly necessary, we recommend that the setReadOnly
function should avoid executing the topology call, or that the topology function be executed only after the connection is fully established.
What plugins are used? What other connection properties were set?
failover,efm
Current Behavior
Based on our direct analysis of the methods, we’ve inferred the following:
- Topology queries are intermittently executed at the end of a transaction.
- These queries are executed within the AWS-provided JDBC wrapper driver.
- The
setReadOnly
method in JDBC cannot be called during a transaction.
Given these points, we hypothesize that the error occurs in the following sequence:
- Transaction ends.
TransactionState
changes toIDLE
.- Under certain conditions, a topology query is executed.
TransactionState
changes back toOPEN
.setReadOnly
method is called.- Error occurs.
Reproduction Steps
When the setReadOnly
function is executed repeatedly, the error described above occasionally occurs.
Possible Solution
I’d like to propose that the Aurora wrapper driver don't trigger the topology call by default when setReadOnly
is invoked.
Referencing the code in question: SubscribedMethodHelper.java, line 59.
Additional Information/Context
I'd be happy to create a PR to help fix this issue :)
The AWS Advanced JDBC Driver version used
2.2.3
JDK version used
correctto-17 17.0.9
Operating System and version
macOS 15.0.1 (24A348)