Skip to content

Commit

Permalink
time out on failed PG connections from database provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Aug 14, 2024
1 parent 04eb2f9 commit ee57d18
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/oss/postgres/prepare/database/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
providerPkg = "namespacelabs.dev/foundation/library/oss/postgres"
connBackoff = 1500 * time.Millisecond
connIdleTimeout = 15 * time.Minute
connTimeout = 5 * time.Minute

caCertPath = "/tmp/ca.pem"
)
Expand Down Expand Up @@ -140,6 +141,9 @@ func connect(ctx context.Context, cluster *postgresclass.ClusterInstance, db str
}
cfg.ConnectTimeout = connBackoff

ctx, cancel := context.WithTimeout(ctx, connTimeout)
defer cancel()

// Retry until backend is ready.
return backoff.RetryWithData(func() (*pgx.Conn, error) {
conn, err := pgx.ConnectConfig(ctx, cfg)
Expand Down

0 comments on commit ee57d18

Please sign in to comment.