Skip to content

Spring transactional resources leak #3394

@justin-tay

Description

@justin-tay

There is a transactional resource leak when using Spring Boot when spring.jpa.open-in-view=true which is the default setting when the async request times out which causes the entity manager to be closed by the OpenEntityManagerInViewInterceptor due to how PlatformJpaTransaction uses entityManager.isOpen as a condition before rolling back the transaction.

Subsequent requests using the thread will all fail when the JpaTransactionManager attempts to start a transaction as the ConnectionHolder is still bound to the thread local in TransactionSynchronizationManager.

org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! JpaTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single JpaTransactionManager for all transactions on a single DataSource, no matter whether JPA or JDBC access.

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