Skip to content

driver: bad connection when no query for hours #214

@tlightsky

Description

@tlightsky

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

Activity

forward32

forward32 commented on Oct 9, 2019

@forward32

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

tlightsky commented on Oct 9, 2019

@tlightsky
Author

@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

forward32 commented on Oct 9, 2019

@forward32

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

tlightsky commented on Oct 9, 2019

@tlightsky
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

awskii commented on Aug 21, 2021

@awskii

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

kshvakov commented on Jan 19, 2022

@kshvakov
Collaborator

ResetSession added in V2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tlightsky@kshvakov@forward32@awskii

        Issue actions

          driver: bad connection when no query for hours · Issue #214 · ClickHouse/clickhouse-go