Skip to content

Transaction(s) stuck after connection limit reached #115

Open
@st1906

Description

@st1906

Hi, lets say we have the following

@transactional(PROPAGATION.REQUIRED)
create(){
 // insert something to DB
}

And the max connection limit set in typeorm is reached (lets say 2)

calling the method twice like this

await Promise.all([myService.create(), myService.create()])

produces the following logs and makes the service unable to do any additional queries to the DB.

Transactional@1675616291035|default|create|undefined|REQUIRED - Before starting: isCurrentTransactionActive = undefined
Transactional@1675616291037|default|create|undefined|REQUIRED - Before starting: isCurrentTransactionActive = undefined
query: START TRANSACTION
Transactional@1675616291035|default|create|undefined|REQUIRED - runWithNewTransaction - set entityManager in context: isCurrentTransactionActive: true
query: START TRANSACTION
Transactional@1675616291037|default|create|undefined|REQUIRED - runWithNewTransaction - set entityManager in context: isCurrentTransactionActive: true

It looks like when the pool size is reached, the methods try to create transactions and lock each other(?). Setting the PROPAGATION to mandatory makes it work. If anyone has a better understanding what is happening (and if this is expected behavior?), would appreciate an answer. (Same issue can be reproduced if the connection limit is raised at 5 or 10, and 5 or 10 calls are made)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions