Skip to content

Unexpected Transaction State Error on Repeated setReadOnly Calls in AWS Aurora Wrapper #1168

Closed
@erie0210

Description

@erie0210

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:

  1. Transaction ends.
  2. TransactionState changes to IDLE.
  3. Under certain conditions, a topology query is executed.
  4. TransactionState changes back to OPEN.
  5. setReadOnly method is called.
  6. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpending releaseResolution implemented, pending official release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions