From 4f0afac8877288746b0da64c6d9ee479dfee81bb Mon Sep 17 00:00:00 2001
From: Kunal Gupta <39487888+iamKunalGupta@users.noreply.github.com>
Date: Mon, 20 May 2024 10:23:57 +0530
Subject: [PATCH] feat: add timeouts to clickhouse

---
 flow/connectors/clickhouse/clickhouse.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/flow/connectors/clickhouse/clickhouse.go b/flow/connectors/clickhouse/clickhouse.go
index d19b5dbedb..7684fbb136 100644
--- a/flow/connectors/clickhouse/clickhouse.go
+++ b/flow/connectors/clickhouse/clickhouse.go
@@ -8,6 +8,7 @@ import (
 	"fmt"
 	"net/url"
 	"strings"
+	"time"
 
 	"github.com/ClickHouse/clickhouse-go/v2"
 	_ "github.com/ClickHouse/clickhouse-go/v2/lib/driver"
@@ -184,6 +185,13 @@ func connect(ctx context.Context, config *protos.ClickhouseConfig) (*sql.DB, err
 				{Name: "peerdb"},
 			},
 		},
+		Settings: map[string]any{
+			"idle_timeout":    10000,
+			"connect_timeout": 10000,
+			"send_timeout":    10000,
+			"receive_timeout": 10000,
+		},
+		ReadTimeout: 10000 * time.Second,
 	})
 
 	if err := conn.PingContext(ctx); err != nil {