keepalive_* connection args being ignored? #1722
                  
                    
                      danielfernandez
                    
                  
                
                  started this conversation in
                General
              
            Replies: 2 comments
-
| 
         I would have expected the same, but I don't know precisely how this feature work. This feature is part of the libpq, and I expect the libpq to mostly configure some configuration on the TCP socket. So my suggestion would be to grep for  If you have any useful information please let us know!  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| 
         @danielfernandez Did you determine if psycopg2 was respecting the   | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm using
psycopg2-binary==2.9.9to connect to a PostgreSQL-compatible database. In between, a load balancer is configured to close any connection idle for more than 30 secs, and some of my queries may take more than that to return the first result, which makes the load balancer close the connection. I configure thekeepalives_*connection arguments, but using Wireshark I don't see any TCP Keep-Alive messages — except in macOS.Scenario
In order to reproduce this, I'm using a regular PostgreSQL 12 server behind the load balancer, and emulating the delay in returning the first result with
pg_sleep(...). But I'm also checking simply having the connection open with the PostgreSQL sessionidlefor some time between (shorter) queries:Sample 1:
Sample 2:
I've tested both code samples above as:
jupyter/datascience-notebook:x86_64-ubuntu-22.04)In all cases the client was in a separate machine to the gateway and the PostgreSQL server (i.e. no UNIX domain sockets should be involved). I've tried both with and without setting the
tcp_user_timeoutargument.Checking with Wireshark, only when executing from macOS Montery can I see the TCP Keep-Alives being sent to
thegateway.Is this expected? Am I missing any bits of configuration? My understanding is that this should have worked at least on Linux (including the Ubuntu Docker image)…
Beta Was this translation helpful? Give feedback.
All reactions