Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-270

Propagate connection read-only fails always when you are using Spring Data repositories implementation and custom isolation level enabled

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Unresolved
    • Icon: Minor Minor
    • 3.0
    • 2.7
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      In 2.7 has been release the feature AG-255 with this  changes 

      We have found a issue when we are working in a spring boot application with custom isolation level enabled and any Spring JDBC repository, as SimpleJpaRepository, because they are annotated with @Transactional( read-only=true) and when we upgraded to 2.7 version the SQLExceptin "Attempted to modify read-only state while enlisted in transaction" is always raised.

       

      Detailed description:

      When you are using springboot and enable custom isolation level by default spring use IsolationLevelDataSourceAdapter. As you can see the method doGetConnection(..)

      First of all, retrieve the connection. Inside retrieve connection logic, in a moment of the process, the class NarayanaTransactionIntegration takes the control and it associates the current transaction to the connection.

      A the ending of association process, the transaction is started using  ConnectionHandler and this sets enlist attribute to true.


      And finally, finish the retrieve connection process and IsolationLevelDataSourceAdapter continues retrieving the read-only value of current transaction. If this one is read-only, the code try to set read-only value to the connection in ConnectionWrapper:

      In the second line handler try to verify Read-only attribute and
      enlisted attribute is always true because the retrieve connection proces previously set it to true.

        1. image-2025-08-18-12-43-06-858.png
          32 kB
          Francisco Barbudo
        2. image-2025-08-18-12-44-17-350.png
          64 kB
          Francisco Barbudo
        3. image-2025-08-18-12-45-31-729.png
          30 kB
          Francisco Barbudo
        4. image-2025-08-18-12-45-59-715.png
          24 kB
          Francisco Barbudo
        5. image-2025-08-18-12-47-05-557.png
          22 kB
          Francisco Barbudo

              graben1181 Benjamin Graf
              franciscobru Francisco Barbudo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: