Search code examples
springhikaricp

Does each stacked transaction use a separate connection?


I have multiple stacked transactions created by calling stacked methods with:

@Transactional(propagation = Propagation.REQUIRES_NEW)

so the result is transaction waiting for new transaction waiting for new transaction...

Do each of these transactions use a separate db connection from the connection pool, possibly starving the pool?

P.S.: I know that I shouldn't stack new transactions due to errors not rolling back all transactions, but I'm curious about the behaviour.


Solution

  • Yes, when you are using REQUIRES_NEW you will get a new transaction for every method call . New transaction means, new database connection from the pool is being used.

    And yes, that means potentially starving it.