Skip to content
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