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

3

8

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.

Alinaaline answered 17/6, 2017 at 23:4 Comment(0)
A
2

Use CONN_MAX_AGE: 0 when using gevent.

Alinaaline answered 17/6, 2017 at 23:29 Comment(0)
P
6

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.

Pejsach answered 18/6, 2017 at 11:1 Comment(1)
This issue has been fixed by Google! Now there is a way - cloud.google.com/sql/docs/postgres/flags#postgres-m . @rvs, good find! Please update your answer :)Soosoochow
A
2

Use CONN_MAX_AGE: 0 when using gevent.

Alinaaline answered 17/6, 2017 at 23:29 Comment(0)
C
0

See the relation between memory and Max concurrent connections here: https://cloud.google.com/appengine/docs/standard/java/cloud-sql/pricing-access-limits

I solved my problem using Postgresql (for now).

I set up more memory for the database

Cranwell answered 8/6, 2018 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.