hard20 pts · first answer countstransactionsdatabase-performancearchitecture
Payment call inside a transaction
Under load this checkout starts failing with connection pool timeouts and lock waits, even though the queries themselves are fast. What is the main problem?
await prisma.$transaction(async (tx) => {
const order = await tx.order.update({
where: { id },
data: { status: 'PAYING' },
})
await paymentProvider.charge(order.total) // 300 ms to 5 s
await emailService.sendReceipt(order.email) // 200 ms
await tx.order.update({ where: { id }, data: { status: 'PAID' } })
})Discussion 0
Join free to post in the discussion.
Related questions
- What an index costsFull Stack Developer
- Moving credits between accountsFull Stack Developer
- Composite index column orderFull Stack Developer
- GraphQL author lookupsFull Stack Developer
- Write skew under snapshot isolationFull Stack Developer
- Choosing an API contract approachFull Stack Developer
- Atomicity in a money transferBackend Developer
- Isolation levels and dirty readsBackend Developer