Skip to content

database: close pgxpool on db.Close and apply pool defaults to pgxpool - #4

Open
adamdecaf wants to merge 1 commit into
stevemsmith:fix/alloydb-failover-recoveryfrom
adamdecaf:fix/alloydb-pgxpool-close-and-defaults
Open

database: close pgxpool on db.Close and apply pool defaults to pgxpool#4
adamdecaf wants to merge 1 commit into
stevemsmith:fix/alloydb-failover-recoveryfrom
adamdecaf:fix/alloydb-pgxpool-close-and-defaults

Conversation

@adamdecaf

Copy link
Copy Markdown

Summary

Follow-up fixes for moov-io#490.

  1. Close pgxpool (and AlloyDB dialer) when *sql.DB is closed
  2. Apply ConnectionsConfig defaults on pgxpool, not database/sql

See commit message for details.

stdlib.OpenDBFromPool does not close the underlying pool when *sql.DB is
closed, leaking connections and the health-check goroutine. Wrap the pool
connector with io.Closer so db.Close() shuts down the pgxpool and AlloyDB
dialer.

Also stop applying ConnectionsConfig via database/sql setters for Postgres:
those do not configure pgxpool, and SetMaxIdleConns(n>0) breaks
OpenDBFromPool. Map resolved defaults onto pgxpool instead so unset MaxOpen
does not silently fall back to max(4, NumCPU()).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant