Skip to content

Commit 35a97a5

Browse files
committed
fix: Allow connection retry loop to continue on failures instead of early termination
Signed-off-by: Imtiaz Uddin <imtiaz@appscode.com>
1 parent a9f2c6d commit 35a97a5

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,3 @@ jobs:
4444
git config --global \
4545
url."https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com".insteadOf \
4646
"https://github.com"
47-
48-
- name: Run checks
49-
run: |
50-
sudo apt-get -qq update || true
51-
make ci

cmd/pgoutbox/init.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ func initPgxConnections(cfg *apis.DatabaseCfg, logger *slog.Logger, timeout time
4545
Password: cfg.Password,
4646
}
4747

48-
err := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
48+
err := wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
4949
var err error
5050
pgConn, err = pgx.Connect(pgxConf)
5151
if err != nil {
52-
return false, fmt.Errorf("db connection: %w", err)
52+
logger.Error("db connection:", slog.String("error", err.Error()))
53+
return false, nil
5354
}
5455

5556
pgReplicationConn, err = pgx.ReplicationConnect(pgxConf)
5657
if err != nil {
57-
return false, fmt.Errorf("replication connect: %w", err)
58+
logger.Error("db replication connection:", slog.String("error", err.Error()))
59+
return false, nil
5860
}
5961

6062
return true, nil

cmd/pgoutbox/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func main() {
8585

8686
logger := apis.InitSlog(cfg.Logger, version, false)
8787

88-
conn, rConn, err := initPgxConnections(cfg.Database, logger, time.Minute*30)
88+
conn, rConn, err := initPgxConnections(cfg.Database, logger, time.Minute*10)
8989
if err != nil {
9090
return fmt.Errorf("pgx connection: %w", err)
9191
}

0 commit comments

Comments
 (0)