Skip to content

Potential Logging Issue with Interaction Between Spring Boot @Transactional and R2DBC H2's readOnly Property #247

@guqing

Description

@guqing

Hello R2DBC H2 Team,

I hope this message finds you well. I'm reaching out to discuss a potential issue I've encountered while integrating R2DBC H2 with Spring Boot.

Description:

In a project using Spring Boot and R2DBC H2, I've observed that whenever a method in the repository layer is annotated with @Transactional, R2DBC H2 consistently logs a message about the connection's read-only status.

This behavior was noted during my usage of these technologies, and after a thorough search through existing issues and discussions on GitHub, as well as a comprehensive review of relevant topics on Stack Overflow, I couldn't find any mention or solution to this specific scenario.

The issue seems to be related to how the readOnly property is handled in R2DBC H2, specifically in H2Connection.java (refer to code: H2Connection.java Line 96.

Issue:

In R2DBC H2, readOnly is a Boolean type, allowing for null, true, or false values. However, in Spring Boot's @Transactional annotation, readOnly is a primitive boolean type with a default value of false. This results in R2DBC H2 logging a read-only state message even when the readOnly attribute in the @Transactional annotation is not explicitly set (thus, defaulting to false). This could lead to some confusion, as developers might mistakenly think that some transactions are incorrectly set to read-only.

Questions:

  • Is it intentional for R2DBC H2 to handle the readOnly attribute in this manner?
  • Is this logging behavior as expected?
  • Is there a possibility to adjust R2DBC H2 to better accommodate the interaction with Spring Boot's @Transactional annotation?

Additional Information:

  • Spring Boot version: 3.2.0
  • R2DBC H2 version: 1.0.0-RELEASE

I appreciate any guidance or information you can provide on this matter. Thank you for your time and dedication to maintaining this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions