You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #1718 we can use a pooled connector with sql.DB, passing a connector and using the interface.
However, when an interface user closes the connection using sql.DB.Close(), the inner logic tries to close the connector if possible:
func (db *DB) Close() error {
...
if c, ok := db.connector.(io.Closer); ok {
err1 := c.Close()
...
But since the connector does not satisfy the interface, the pool is not closed and the connections leak.
The request here is to add the Close() method to the connector for cases when it has a pool, in a similar manner it branches in the func (c connector) Connect method.
The text was updated successfully, but these errors were encountered:
Closing the sql.DB shouldn't close the underlying pgxpool.Pool. It's entirely possible to create a pgxpool.Pool, use it to create sql.DB, close the sql.DB, and keep using the pgxpool.Pool.
@jackc
With that you are suggesting that users use both sql.DB and pgxpool.Pool for DB operations?
In the docs you specifically have a section that describes how to pick between the two when opening a new connection.
My assumption is that users that choose one don't also use the other, if that is a real use case, then I will close this issue.
Since #1718 we can use a pooled connector with
sql.DB
, passing a connector and using the interface.However, when an interface user closes the connection using
sql.DB.Close()
, the inner logic tries to close the connector if possible:But since the connector does not satisfy the interface, the pool is not closed and the connections leak.
The request here is to add the
Close()
method to the connector for cases when it has a pool, in a similar manner it branches in thefunc (c connector) Connect
method.The text was updated successfully, but these errors were encountered: