Skip to content

fix(server): retry initial connection to postgres #7325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! fix(server): retry initial connection to postgres
  • Loading branch information
coadler committed Apr 28, 2023
commit 7e9c81af3af05a507e84dcf23fec2f0bcab80404
9 changes: 5 additions & 4 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1762,15 +1762,16 @@ func connectToPostgres(ctx context.Context, logger slog.Logger, driver string, d

break
}
if err != nil {
return nil, xerrors.Errorf("connect to postgres; tries %d; last error: %w", tries, err)
}

// Make sure we close the DB in case it opened but the ping failed for some
// reason.
defer func() {
if !ok && sqlDB != nil {
_ = sqlDB.Close()
}
}()
if err != nil {
return nil, xerrors.Errorf("connect to postgres; tries %d; last error: %w", tries, err)
}

// Ensure the PostgreSQL version is >=13.0.0!
version, err := sqlDB.QueryContext(ctx, "SHOW server_version_num;")
Expand Down