Skip to content

Commit

Permalink
Reset expired connections
Browse files Browse the repository at this point in the history
  • Loading branch information
iamluc committed Feb 8, 2023
1 parent ca2569e commit 30e0a34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import (
"context"
"crypto/tls"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2/resources"
"github.com/pkg/errors"
"io"
"log"
"net"
"os"
"syscall"
"time"

"github.com/ClickHouse/clickhouse-go/v2/resources"
"github.com/pkg/errors"

"github.com/ClickHouse/ch-go/compress"
chproto "github.com/ClickHouse/ch-go/proto"
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
Expand Down Expand Up @@ -151,6 +152,11 @@ func (c *connect) isBad() bool {
case c.closed:
return true
}

if time.Since(c.connectedAt) >= c.opt.ConnMaxLifetime {
return true
}

if err := c.connCheck(); err != nil {
return true
}
Expand Down

0 comments on commit 30e0a34

Please sign in to comment.