]> Cypherpunks repositories - gostls13.git/commit
database/sql: Fix idle connection reuse
authorSteven Hartland <steven.hartland@multiplay.co.uk>
Tue, 9 Jun 2020 07:58:08 +0000 (08:58 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 3 Nov 2021 19:32:33 +0000 (19:32 +0000)
commit74f99d0933d5c201fc17d90ab612cd1a9c7d425f
treed7efa1d13bc730c263ab003a902f0eee57debae1
parentcfd016df1fba2a2a104f4cca705aa4357777986b
database/sql: Fix idle connection reuse

Fix idle connection reuse so that ConnMaxIdleTime clears down excessive
idle connections.

This now ensures that db.freeConn is ordered by returnedAt and that
connections that have been idle for the shortest period are reused
first.

In addition connectionCleanerRunLocked updates the next check deadline
based on idle and maximum life time information so that we avoid waiting
up to double MaxIdleTime to close connections.

Corrected the calling timer of connectionCleaner.

Fixes #39471

Change-Id: I6d26b3542179ef35aa13e5265a89bc0f08ba7fa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/237337
Reviewed-by: Tamás Gulácsi <tgulacsi78@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
src/database/sql/sql.go
src/database/sql/sql_test.go