Commit 74f99d09 authored by Steven Hartland's avatar Steven Hartland Committed by Ian Lance Taylor
Browse files

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: default avatarTamás Gulácsi <tgulacsi78@gmail.com>
Reviewed-by: default avatarDaniel Theophanes <kardianos@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
parent cfd016df
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment