FATAL: remaining connection slots are reserved for non-replication superuser connections

We started seeing this error sometimes over the last few days... We are mainly using @supabase/supabase-js in node. We are runing ~10-15 queries per second there. (The error came from here) We also connect to the connection pooler for an internal monitor (low traffic, a handful of < 1s queries being run every 10 minutes) Are there issues with combining these connection methods? Any ideas what could be causing the error?
15 Replies
Socal
Socal2y ago
have you tried increasing your pool size in the database settings?
Reilly Sweetland
Reilly SweetlandOP2y ago
Thx for quick response. Not yet. Is there any reason we should not bump this to the maximum our plan allows for? (Assuming CPU, mem, etc looks ok) Of note, these are not realtime connections. I'm assuming it's tracking the same metric?
garyaustin
garyaustin2y ago
realtime connections are something totally different. Those use websockets. Supabase-js goes thru PostgREST which has its own pooler and comes in as authenticator role in the the role info view where you can see connections per role.
Reilly Sweetland
Reilly SweetlandOP2y ago
Got it. I just found what I was looking for. It's listed under compute add-ons: https://supabase.com/docs/guides/platform/compute-add-ons
Compute Add-ons | Supabase Docs
Learn about your project's instance and additional add-ons.
garyaustin
garyaustin2y ago
I don't think your 10-15 query load per second is going to tax PostgREST as far as connections. Are any other roles using alot of connections?
Reilly Sweetland
Reilly SweetlandOP2y ago
I was thinking the same thing. Even for query optimization I would prefer to just have the sql. It's only one role. (the project changed directions) It's a long-running process, so I'm thinking we will manage our own pool with pg
garyaustin
garyaustin2y ago
What is the long-running process?
Reilly Sweetland
Reilly SweetlandOP2y ago
Also, for anyone else stumbling here, exact connection limits for your plan are here: https://supabase.com/dashboard/project/{your-project-id}/settings/addons
Add ons | Supabase
Supabase Studio
Reilly Sweetland
Reilly SweetlandOP2y ago
It's a daemon-type system. Looping and continuously querying. separately, there is an event system which is more ephemeral neither is serverless
garyaustin
garyaustin2y ago
Still not clear, but does not probably matter. PostgREST calls from REST API do not maintain any connection to the database. They do their thing then PostgREST is free to reuse the connection or not.
Reilly Sweetland
Reilly SweetlandOP2y ago
Good to know. Initially I used the client / REST API because I figure you guys would have optimized for volatility / worst-case traffic patterns. Sounds like that is a good option still. Thanks for the background info, and super fast response
garyaustin
garyaustin2y ago
"you guys" most of us here are users.
Reilly Sweetland
Reilly SweetlandOP2y ago
You're not on Supabase team?? I thought I saw a badge
garyaustin
garyaustin2y ago
I'm part of their Supasquad which is a users program they have.
Reilly Sweetland
Reilly SweetlandOP2y ago
Got it. Well, thanks for the help anyway. Much appreciated.

Did you find this page helpful?