hyperledger / hyperledger/fabric-ca

Expose Postgres database connection configuration properties including max connection lifetime

Open
#321 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
453
Forks
714
Avg merge
7h 23m
Merged PRs (30d)
3

Description

Configuring the max lifetime for the Postgres database connection type, and likely all others, like [maxLifetime](https://github.com/brettwooldridge/HikariCP#frequently-used) in HikariCP would allow for regular connection cycling on a configured lifetime duration. I believe the default is "0" in the database/sql library, or infinite lifetimes.

PQ says it "Handles bad connections for database/sql" and [line 727 func TestCloseBadConn](https://github.com/lib/pq/blob/master/conn_test.go#L727) seems to indicate PQ will recover from bad connections, that seem to last for an infinite timeframe, though I have seen in production stale connection pools not recycle stale connections. If we have access to the underlying configuration properties then we can manually configure the connection lifecycle.

The configuration properties I have in mind are as indicated in [this article](https://www.alexedwards.net/blog/configuring-sqldb):

db.SetMaxOpenConns(25)
db.SetMaxIdleConns(25)
db.SetConnMaxLifetime(5*time.Minute)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.