Prisma Error Management #27395
TheOtherBrian1
announced in
Troubleshooting
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Addressing Specific Errors:
Prisma, unlike other libraries, uses query parameters for configurations.
Some can be used to address specific errors and can be appended to end of your connection string like so:
Can't reach database server at
:Increase
connect_timeout
to 30s and check to make sure you are using a valid connection string.Timed out fetching a new connection from the connection pool
:Increase
pool_timeout
to 30s .... prepared statement "" already exists
Add pgbouncer=true to the connection string.
Max client connections reached
Checkout this guide for managing this error
Server has closed the connection
According to this GitHub Issue for Prisma, it may be related to large return values for queries. Try to limit the total amount of rows returned for particularly large requests.
Drift detected: Your database schema is not in sync with your migration history
Prisma will try to act as the source of truth for your database structures. If you
CREATE
,DROP
, orALTER
database objects outside of a Prisma Migration, it is likely to detect drift and may offer to correct the situation by purging your schemas. To circumvent this issue, try baselining your migrations.Some users have discussed how they managed this problem in a GitHub Discussion.
Management Suggestions
Make a custom role for Prisma to increase observability
Imagine your database as a house, and users as the people with keys.
postgres
role) to access everything. But it's safer to give Prisma its own key! This way, it can only access the rooms (tables) it needs.Creating the Prisma User:
Give Postgres Ownership of the New User:
This allows you to view Prisma migration changes in the Dashboard
Keep it safe!
Use a strong password for Prisma. Bitwarden provides a free and simple password generator that can make one for you.
If you need to change it later, you can use the below SQL:
Grant Prisma Access
The below example gives Prisma full authority over all database objects in the public schema:
Optimize Prisma Queries:
In the Query Performance Advisor, you can view long-running or frequently accessed queries by role:
Selecting a query can reveal suggestions to improve its performance
Configuring Connections
Useful Links:
Supabase provides 3 connection strings in the Database Settings. You can use all three or just the ones most relevant to your project.
Direct Connection:
Best used with stationary servers, such as VMs and long-standing containers, but it only works in IPv6 environments unless the IPv4 Add-On is enabled. If you are unsure if your network is IPv6 compatible, check here.
Supavisor in Session Mode (port 5432):
An alternative to direct connections when working in IPv4-only environments.
Supavisor in Transaction Mode (port 6543):
Should be used when deploying to:
When working in serverless/edge environments, it is recommended to set the
connection_limit=1
and then gradually increase it if necessary.Beta Was this translation helpful? Give feedback.
All reactions