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
DB.SetMaxOpenConns could reduce the connection pool size, but the unnecssary connections won't close until DB's free connection size >= DB's idle connections size.
That is to say, when the pool is busy (lots of requests), the unnecessary connections won't be closed.
*************** func (db *DB) putConn(dc *driverConn, er
*** 797,802 ****
--- 797,806 ----
// If a connRequest was fulfilled or the *driverConn was placed in the
// freeConn list, then true is returned, otherwise false is returned.
func (db *DB) putConnDBLocked(dc *driverConn, err error) bool {
+ if db.numOpen > db.maxOpen {
+ return false
+ }
+
if c := len(db.connRequests); c > 0 {
req := db.connRequests[0]
// This copy is O(n) but in practice faster than a linked list.
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
database.sql: dynamic reduce the connection pool size
database/sql: dynamic reduce the connection pool size
Dec 27, 2014
-- See https://golang.org/doc/contribute.html on how to use Gerrit & git-codereview (we don't take or comment on patches on the issue tracker or in pull requests)
-- Include a new test
-- Write a detailed and self-contained (without referencing a thread elsewhere) commit message explaining the problem and fix.
DB.SetMaxOpenConns could reduce the connection pool size, but the unnecssary connections won't close until DB's free connection size >= DB's idle connections size.
That is to say, when the pool is busy (lots of requests), the unnecessary connections won't be closed.
detailed discussion on golang-nuts
my patch to src/database/sql/sql.go
The text was updated successfully, but these errors were encountered: