question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired' P2028

See original GitHub issue

Bug description

"Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'."

I’m using 3.14.0 I increased timeouts and these queries generally take ~500ms though they can take longer under load

{
      maxWait: 20000, // default: 2000
      timeout: 60000, // default: 5000
    }
{"is_panic":false,"message":"Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.","meta":{"error":"Transaction already closed: Transaction is no longer valid. Last state: 'Expired'."},"error_code":"P2028","clientVersion":"3.14.0"} 

Slack thread: https://prisma.slack.com/archives/CCWDULGUW/p1654457710257189

How to reproduce

Do a bunch of complex interactive transactions in different lambda functions running in parallel

Expected behavior

No response

Prisma information

3.14.0, in a lambda layer serverless stack

Environment & setup

  • OS: Lambda
  • Database: Postgres
  • Node.js version: 14

Prisma Version

prisma                  : 3.14.0
@prisma/client          : 3.14.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 2b0c12756921c891fec4f68d9444e18c7d5d4a6a
Studio                  : 0.460.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:12
  • Comments:42 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
manojmpc91commented, Jun 30, 2022

Yes this bug keeps troubling and blocks the development. Have tried killing idle processes, disconnecting all open connections, stopping database server but nothing works. Somehow it finds that some transaction was not closed properly.

This issue was closed with https://github.com/prisma/prisma/issues/9584 in version 3.9 I have version 3.14 but the issue still exists.

5reactions
felipdccommented, Sep 2, 2022

Any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

any suggestions about what to do with this error Transaction
"Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'." I'm using 3.14.0 I increased timeouts and these ...
Read more >
How to use $transaction API in this scenario? - prisma
a will never be inserted into the database as the prisma.user.create() command will only be called inside prisma.$transaction so you do not ......
Read more >
Transactions and batch queries (Reference) - Prisma
This page explains the transactions API of Prisma Client.
Read more >
Prisma 4.7.0 Release - GitClear
Interactive transactions are now Generally Available · Relation mode is Generally Available · Prisma Client Extensions (Preview) · Multi-schema ...
Read more >
It's Prisma Time - Transactions - DEV Community ‍ ‍
So, can Prisma not handle them? Obviously the answer is no. In this moment, Prisma handles the transactions in two ways, the first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found