Answer the question
In order to leave comments, you need to log in
How to fix FATAL: remaining connection slots are reserved for non-replication superuser connections?
I rummaged through a bunch of information, I didn’t find the answer, or I’m looking badly.
There is Django 3.2, there is postgres, there are a bunch of direct SQL queries through
with connection.cursor() as cursor:
cursor.execute
SET SESSION idle_in_transaction_session_timeout = '2min';
CONN_MAX_AGE = 120
SELECT pg_terminate_backend(pid)
FROM inactive_connections
WHERE rank > 1;
Answer the question
In order to leave comments, you need to log in
That is, closing the connection at the code level..
Connections can be used as context managers. Note that a context wraps a transaction: if the context exits with success the transaction is committed, if it exits with an exception the transaction is rolled back. Note that the connection is not closed by the context and it can be used for several contexts
SET SESSION idle_in_transaction_session_timeout = '2min';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question