Skip to content
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

driver: bad connection when no query for hours #214

Closed
tlightsky opened this issue Sep 29, 2019 · 6 comments
Closed

driver: bad connection when no query for hours #214

tlightsky opened this issue Sep 29, 2019 · 6 comments

Comments

@tlightsky
Copy link

tlightsky commented Sep 29, 2019

all our etl service which dong insert into table once per hours will got
this bad connection error
driver version is 1.3.11

@forward32
Copy link

CH has idle_connection_timeout option with default value 1 hour. If you do nothing within this time CH closes your connection.

Solutions:

  1. just increase this value
  2. use separate goroutine with some activity (e.g. ping)

@tlightsky
Copy link
Author

tlightsky commented Oct 9, 2019

@forward32
we suspect that too,
and we tried a db.Ping() every 30 second,
still got the bad connection error,
maybe we need to select now() rather than db.Ping()

@forward32
Copy link

Hm, I use second approach (ping once in minute) and it works fine for me.

Try to:

  1. check your value of idle_connection_timeout
  2. check error logs in CH
  3. capture traffic between your app and CH and investigate it for some anomalies

@tlightsky
Copy link
Author

@forward32
for now, we try to reconnect if it failed for the first time insertion,
will try to investigate the reason later,
thanks for reply

@awskii
Copy link

awskii commented Aug 21, 2021

Previously, db.Ping did not return error at all (driver bug), so you needed to SELECT 1; in a for loop, and reconnect, if select fails.
Looks like something never changes, and that's why I'm here.

@kshvakov
Copy link
Collaborator

ResetSession added in V2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants