Supabase/Prisma DB Issues
Hi all,
We've noticed a few different issues with our postgres instance via Prisma (hosted in Supabase). We're having a hard-time identifying what's missing in order to fix these errors. Ideally, something is misconfigured / with your help, we can fix these issues. Database health wise, utilization on average seems healthy (but has spiked some days). We use Primsa as our ORM / many of these errors are in Prisma-speak
Here are some of the errors we've seen:
- Error in connector: error querying the database: unexpected message from server
- Can't reach database server at ...
- Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 30, connection limit: 1)
- Transaction API error: Transaction already closed: A batch query cannot be executed on an expired transaction. The timeout for this transaction was 5000 ms, however 6357 ms passed since the start...
- Server has closed the connection.
- X does not exist -> this one has many forms, sometimes tables/relations
relation "Product" does not exist
, sometimes extensions type "hstore" does not exist"
. In each case we've seen, the extension/relation does in fact exist/wasn't modified
It's possible that some of these errors are unrelated - but in general it's caused a lot of flakiness / we'd like a more reliable database.
Things we're looking into:
- Increasing the connection_limit from 1 to 5 in our DB_URL (postgres://postgres.<project_id>:***@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=1&pool_timeout=30)
Beyond this, we're unsure what we need to do to get our database healthy again.Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
1 Reply
Hello @santi 👋
We've noticed a few different issues with our postgres instance via PrismaJust to clarify, postgres instance via Prisma mean you are using a database hosted by Supabase and using Prisma ORM and not Prisma Postgres as your database right? Are all these errors completely random or do they occur for a specific query/table?
Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 30, connection limit: 1)Based on this error message, your connection limit is too low, so you should definitely increase connection limit https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool#setting-the-connection-pool-size
Transaction API error: Transaction already closed: A batch query cannot be executed on an expired transaction. The timeout for this transaction was 5000 ms, however 6357 ms passed since the startHere you should increase the interactive transaction timeout by passing timeout parameter as in this example: https://www.prisma.io/docs/orm/prisma-client/queries/transactions#transaction-options
Prisma
Prisma Postgres | Instant Global Databases
Free to start, no setup, no commitments. Easily grow your database as your app scales.
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
Transactions and batch queries (Reference) | Prisma Documentation
This page explains the transactions API of Prisma Client.
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.