-
Notifications
You must be signed in to change notification settings - Fork 53
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
Unclear "Use of Closed Network Connection" Error #405
Labels
bug
Something isn't working
Comments
abraithwaite
changed the title
Use of Closed Network Connection
Unclear Use of Closed Network Connection Error
May 31, 2024
abraithwaite
changed the title
Unclear Use of Closed Network Connection Error
Unclear "Use of Closed Network Connection" Error
May 31, 2024
charredlot
pushed a commit
to charredlot/ch-go
that referenced
this issue
Jun 24, 2024
…#405) When the server closes the connection unexpectedly, the client will call cancelQuery (e.g. when client.packet fails). In client.cancelQuery, if client.flushBuf has data to flush, it will return a non-nil error and return early without calling conn.Close. This prevents the chpool from removing the client after client.Do and leaves the client.conn in a bad state such that future writes will always fail with a "broken pipe" error.
charredlot
pushed a commit
to charredlot/ch-go
that referenced
this issue
Jun 24, 2024
…#405) When the server closes the connection unexpectedly, the client will call cancelQuery (e.g. when client.packet fails). In client.cancelQuery, if client.flushBuf has data to flush, it will return a non-nil error and return early without calling conn.Close. This prevents the chpool from removing the client after client.Do and leaves the client.conn in a bad state such that future writes will always fail with a "broken pipe" error.
not sure if it's the same issue, but ran into a similar problem with the chpool client getting stuck in a bad state when the server-side disconnects...made a PR here #409 |
charredlot
added a commit
to charredlot/ch-go
that referenced
this issue
Jun 26, 2024
…#405) When the server closes the connection unexpectedly, the client will call cancelQuery (e.g. when client.packet fails). In client.cancelQuery, if client.flushBuf has data to flush, it will return a non-nil error and return early without calling conn.Close. This prevents the chpool from removing the client after client.Do and leaves the client.conn in a bad state such that future writes will always fail with a "broken pipe" error.
ernado
added a commit
that referenced
this issue
Jul 1, 2024
fix(query): always close client.conn in cancelQuery (issue #405)
FWIW, I can see these errors when using a local ClickHouse server standalone instance. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using clickhouse-go with clickhouse-cloud, we observe these errors happening during what we suspect to be auto-scaling events on the cloud side.
I believe it's because clickhouse proactively closes network connections that have encountered some kind of exception? It would be nice to have either a clearer error message here, or even better automatic reconnection / retries in the event of a failure here.
Getting this particular error bubbled up to the application isn't particularly useful. The only thing we can do is kill the client and recreate it before re-issuing the query because we can no longer trust the connection.
To be clear: we are not closing the connection on our end, so for whatever reason clickhouse server has to close the connection proactively, I think this library should be able to catch and handle that situation for a cleaner shutdown with a sentinel error value at the very least so we can make a more informed decision about how to handle it.
Steps to reproduce
Expected behaviour
We get a better error returned or have options to configure retries, or both.
Error log
Configuration
Environment
ClickHouse server
CREATE TABLE
statements for tables involved:The text was updated successfully, but these errors were encountered: