-
Notifications
You must be signed in to change notification settings - Fork 180
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
enabling TCP keepalive to avoid connections getting closed #205
Comments
I think I am having exactly this issue but I cannot tell. I have a long running query and after ~5 minutes, it stops with a failure: |
@ericwoodall It's hard to tell the problem from your description, here are some of directions for debug: The latest vertica-python already set TCP keepalive as default: Source code, except you cannot config keepalive ping parameters (TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT) like the code above. Therefore TCP keepalive should not be the root of your problem if you are using latest version of vertica-python. In addition, vertica-python provides On the other hand, a Broken Pipe error could mean a lot of things. It is possible that your Vertica server closes this connection. So I think it's necessary to check the query itself as well. |
@sitingren thanks for the reply! I feel confident that it is not the query because I can execute the same query in DBViz and it returns data. I am going to install the latest version of both vertica-python and dbt-vertica and see if this fixes it. Will report back. Thanks again! |
@sitingren I installed the latest version of vertica-python (1.0.1) and I am still getting the same broken pipe error. Also, I verified that it is not the query, as I did a table insert [using the same query] and it succeeded. |
@ericwoodall Is DBViz also using vertica-python? Have you toggled |
@sitingren , no DBViz is not using vertica-python but the query returns fine so it is not a server misconfiguration. I am in the process of creating a test python script that uses vertica-python directly. Will report back. |
+1 for I am not expert but
I have a code that have being broken for 1 year due to this error! Any ideas how set socket.SO_KEEPALIVE? |
@C-h-e-r-r-y What vertica-python version are you using? Have you checked out your server configs? |
@sitingren Vertica sever version is
About serverside configs - good idea but I do not know what to try :( |
@sitingren |
@C-h-e-r-r-y Please use the latest vertica-python version if possible. You can inspect the open socket once you create a Connection object: import vertica_python
conn_info = {'host': 'xxx', 'user': 'xxx', ..., 'connection_timeout': 10}
with vertica_python.connect(**conn_info) as conn:
print(conn.socket.gettimeout()) # set by 'connection_timeout'
print(conn.socket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)) # should be 1
print(conn.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE))
print(conn.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL))
print(conn.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT)) |
My steps and result of investigations:
I have not yet investigated this in detail. The only what I can say now is Your post about |
We ran into an issue with NAT gateway closing connections for long running queries that do not stream data back to the client. To fix this, we enabled TCP keepalive on the socket.
I haven't created a PR because this is linux specific code, but wanted to add it here to see if the community finds it useful.
See diff below.
-Thomas
The text was updated successfully, but these errors were encountered: