From 91bc2e9515c90cbac37d3a280c3ad2dae5664ce1 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Sun, 25 Feb 2024 11:37:56 -0500 Subject: [PATCH] replace ping with `SELECT 1` (#1375) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes with replication connections `-- ping` isn't playing well, replace with `SELECT 1` --------- Co-authored-by: Philip Dubé --- flow/connectors/postgres/postgres.go | 2 +- flow/connectors/postgres/ssh_wrapped_pool.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flow/connectors/postgres/postgres.go b/flow/connectors/postgres/postgres.go index 00b4e7b825..5be019f2d5 100644 --- a/flow/connectors/postgres/postgres.go +++ b/flow/connectors/postgres/postgres.go @@ -240,7 +240,7 @@ func (c *PostgresConnector) ConnectionActive(ctx context.Context) error { if c.conn == nil { return errors.New("connection is nil") } - pingErr := c.conn.Ping(ctx) + _, pingErr := c.conn.Exec(ctx, "SELECT 1") return pingErr } diff --git a/flow/connectors/postgres/ssh_wrapped_pool.go b/flow/connectors/postgres/ssh_wrapped_pool.go index 8b3d5d067e..bfb19a48f3 100644 --- a/flow/connectors/postgres/ssh_wrapped_pool.go +++ b/flow/connectors/postgres/ssh_wrapped_pool.go @@ -112,7 +112,7 @@ func (tunnel *SSHTunnel) NewPostgresConnFromConfig( host := connConfig.Host err = retryWithBackoff(logger, func() error { - err = conn.Ping(ctx) + _, err := conn.Exec(ctx, "SELECT 1") if err != nil { logger.Error("Failed to ping pool", slog.Any("error", err), slog.String("host", host)) return err