-
Notifications
You must be signed in to change notification settings - Fork 573
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
Error driver: bad connection #213
Comments
I’m getting the same problem. In general, whenever a query fails, for whatever reason, that seems to leave the connection in a bad state, and the next one will always fail with “bad connection”. After that, everything starts working ok. |
Got this error on "columnar" type of insertion if I try to use the same connection with OpenDirect. Something like that(not real code, just to show the idea):
On the second iteration I got error on
Long story, but on 19.14.6.12-2 same application works perfectly. |
Test case for
With same error in CH:
|
Holly molly, it's here 204d131#diff-17703cbd24e279392c28017efd531a45R163 Cleanup blocks and buffers are okay, but why close connection? And why I'm able to send data after connection is closed? |
@johnatannvmd ClickHouse doesn't support the real transactions, begin/commit/rollback - is a transaction emulation. The connection is closed to prevent ClickHouse corruption (after error driver can send incorrect blocks). |
Same here. |
I'm having similar issues
Is there a known workaround ? |
@cameronbraid |
@qJkee I think that working with the driver directly is supposed to work like that already. Requesting a connection makes the code more verbose, more error handling, and only really needed if you need to do something with the connection object itself. |
FWIW if anybody is working on a fix for |
any updates? |
@kshvakov would like to work on this issue. |
@goku321 , It's Open Source. Of course you can do it!) |
Not able to reproduce it locally. Any help would be appreciated. I'm using precompiled binary for macos. Here's my code:
|
@goku321 This usually happens when server side sockets gets closed abruptly & client tries to re-use the stale connection. Setting |
Hi guys, |
This commit fixes for ClickHouse#213. If the connection closes from the server side for some reason, the database driver returns driver.ErrBadConn to database/sql. Usually, database/sql retries a request, assuming that the error occurs in a function that could be called first after retrieving a connection from the pool. But beginTx in clickhouse-go doesn't perform any network interaction and driver.ErrBadConn is returned later in the transaction. database/sql doesn't retry it because assumes that connection is alive - beginTx didn't return the error. This commit adds a method to check the connection liveness and performs that check in beginTx function. The check is taken from go-sql-driver/mysql#934. There is no way to check the liveness of a secure connection, as long as there is no access to raw TCP net.Conn in clickhouse-go.
This commit fixes for ClickHouse#213. If the connection closes from the server side for some reason, the database driver returns driver.ErrBadConn to database/sql. Usually, database/sql retries a request, assuming that the error occurs in a function that could be called first after retrieving a connection from the pool. But beginTx in clickhouse-go doesn't perform any network interaction and driver.ErrBadConn is returned later in the transaction. database/sql doesn't retry it because assumes that connection is alive - beginTx didn't return the error. This commit adds a method to check the connection liveness and performs that check in beginTx function. The check is taken from go-sql-driver/mysql#934. There is no way to check the liveness of a secure connection, as long as there is no access to raw TCP net.Conn in clickhouse-go.
This commit fixes for ClickHouse#213. If the connection closes from the server side for some reason, the database driver returns driver.ErrBadConn to database/sql. Usually, database/sql retries a request, assuming that the error occurs in a function that could be called first after retrieving a connection from the pool. But beginTx in clickhouse-go doesn't perform any network interaction and driver.ErrBadConn is returned later in the transaction. database/sql doesn't retry it because assumes that connection is alive - beginTx didn't return the error. This commit adds a method to check the connection liveness and performs that check in beginTx function. The check is taken from go-sql-driver/mysql#934. There is no way to check the liveness of a secure connection, as long as there is no access to raw TCP net.Conn in clickhouse-go.
The last patch didn't fix the problem completely: https://github.com/ClickHouse/clickhouse-go/pull/421/files#diff-bf47e8d1e5bf079269e36fce5f142b421ec333fcdc9b0dc8117c63cf175f8984R129 When we begin transaction, the Look at tests please:
|
@co11ter connection pooling and retries are the responsibility of database/sql. So I'm not sure if it's right to try to handle such situation inside the driver. |
I guess solving it on database/sql side is not good idea, since connection pooling in this case allows to send queries of transaction to various connections. It can be inconsistent within some database. Thus it turns out ensuring liveness of connection within transaction is responsibility of driver. |
@co11ter I agree that such a problem can't be solved in database/sql. But what behavior is expected here? |
I suggest to reopen tcp connection if old one is invalid and |
It seems to me more like a new feature than a bug fix 👍 |
Added in V2 75ad13d along with |
This commit fixes for ClickHouse#213. If the connection closes from the server side for some reason, the database driver returns driver.ErrBadConn to database/sql. Usually, database/sql retries a request, assuming that the error occurs in a function that could be called first after retrieving a connection from the pool. But beginTx in clickhouse-go doesn't perform any network interaction and driver.ErrBadConn is returned later in the transaction. database/sql doesn't retry it because assumes that connection is alive - beginTx didn't return the error. This commit adds a method to check the connection liveness and performs that check in beginTx function. The check is taken from go-sql-driver/mysql#934. There is no way to check the liveness of a secure connection, as long as there is no access to raw TCP net.Conn in clickhouse-go.
feat(proto): add missed Array() methods
Use in a go web environment
The text was updated successfully, but these errors were encountered: