Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am seing those errors in cloud sql Postgres logs.

Its a small 1 cpu, 4Gb of ram instance yet this is a bit troublesome. I do not see any max_connections in the customizable flags that could allow me to bypass this error.

The app is a simple Django service with very little queries and load not even exposed to the public.

The immediate solution is for me to start using db connection pooling with pgbouncer or a Django app but that adds up a bit of complexity.

 max_connections 
-----------------
 100

Do we have a way to increase this number?

PS: After digging a bit it seems to come from the use of gevent workers with gunicorn. It was stable < 20 connections before that.

Nevertheless, in case of traffic surge it would be good to know if max_connections can be controlled.

like image 376
coulix Avatar asked Jun 17 '17 23:06

coulix


People also ask

What does remaining connection slots are reserved mean in PostgreSQL?

What causes PostgreSQL “Remaining connection slots are reserved” error? psql: FATAL: remaining connection slots are reserved for non-replication superuser connections Basically, Insufficient connections allocated for PostgreSQL tasks causes the issue. Check what your database max connection is. By default, this value is set to 100.

Why is my PostgreSQL fatal?

psql: FATAL: remaining connection slots are reserved for non-replication superuser connections Basically, Insufficient connections allocated for PostgreSQL tasks causes the issue. Check what your database max connection is. By default, this value is set to 100. To do this execute any one of the queries below against a database within your cluster:

How to fix “PostgreSQL server cannot connect to another server”?

You are getting this error because your server exceeded the limit of max_connections parameter.max_connection. Decrease the value of [superuser_reserved_connections] parameter: You can find above both parameters in postgresql.conf file. Note: After changing parameters, you must restart the PostgreSQL cluster.

How many backend connections can I connect to a PostgreSQL cluster?

Each PostgreSQL cluster allows 25 backend connections per 1 GB of RAM minus 3 connections per node that are reserved for maintenance. Here is a quick overview of the allowed backend connections based on each plan:


1 Answers

Update: now you can set the max_connections setting via Cloud SQL Flags. See https://cloud.google.com/sql/docs/postgres/flags#postgres-m


This was my answer in the time of writing the question:

There is currently no way to increase a limit, but we are aware of this problem. Please follow Issue 37271935 on our issue tracker.

like image 68
rvs Avatar answered Oct 03 '22 20:10

rvs