Skip to content

Commit

Permalink
replace ping with SELECT 1 (#1375)
Browse files Browse the repository at this point in the history
Sometimes with replication connections `-- ping` isn't playing well,
replace with `SELECT 1`

---------

Co-authored-by: Philip Dubé <[email protected]>
  • Loading branch information
iskakaushik and serprex authored Feb 25, 2024
1 parent a989cab commit 91bc2e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flow/connectors/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion flow/connectors/postgres/ssh_wrapped_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91bc2e9

Please sign in to comment.