-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Listener - connection being intermittently dropped when using Postgrest with PGCloudnative backed database. #3778
Comments
There are various timeouts (search "timeout" here). OTOH I don't remember which one affects the LISTEN, maybe the idle_session_timeout. Try querying |
So it is retrying after the LISTEN connection is lost? Please share the full logs. |
Hey @steve-chavez thanks for the help! It is not retrying, I set my postgrest container to have its log-level at debug and when it loses the listener connection it fails silently. I checked, I have found a way to replicate my issue however. When I first boot my container I can see three connections in postgrest's pool: "pid","usename","application_name","query_start","state","query" And if I send a notification on the pgrest channel I can see:
If I terminate these connections recently after the container has booted using:
I can see that Postgrest will retry the listener connection.
If however I wait for some time - I see only one connection: "pid","usename","application_name","query_start","state","query" If I force a re-connection:
Postgrest does not restart the listener:
The timeline is visible in the logs:
Between 11:05 and 11:37 the listener connection died and was not revived by postgrest. Note I manually forced those re-connections between 11:02 and 11:04. Does the Listener have any kind of keep-alive? |
Unfortunately I'm unable to reproduce locally. When I kill the pg connections with pg_terminate_backend, I don't get the @ethanwaldieferry Can you reproduce this reliably? Could you reproduce with a connection to a non-containerized postgres? Or perhaps to a different container image (like https://hub.docker.com/_/postgres) ? |
Environment
Description of issue
We are trying to use the LISTEN/NOTIFY channel to force schema updates to our Postgrest instances. When we first boot our instances the channel seems to be open. However after a period of time (around 5 mins) I can see that the connection running the statement "LISTEN pgrest;" vanishes - with no logs inside postgrest!
If I restart my postgrest instances - I will see this "LISTEN pgrest;" session appear again - however it will still only persist for about 5 minutes.
I am able to trigger schema updates manually using NOTIFY in this 5 min window however I am unable to do so after. I have checked with multiple clients and can see other clients are receiving events - however postgrest is not.
I also ensured that POSTGREST was connected to the primary - directly without the presence of any load balancer.
Strangely I have a different cluster in K8s that is based on the Patroni operator where I do not have this issue.
Has anyone seen this before? Where the listener simply stop after a period of time and the connection vanishes.
The weirder part is that sometimes hours or days later the listener will come back online for a short while - only to disappear again.
My questions:
Other experiements:
Any ideas on this would be much appreciated. Ive really been running around in circles on this one!
The text was updated successfully, but these errors were encountered: