database/sql: add `lastUseTime` or similar to driverConn, add SetConnMaxIdleLefttime to DB #25232
changed the title
[feature] database/sql add `lastUseTime` or similar to driverConn, add SetConnMaxIdleLefttime to DB
May 3, 2018
I don't fully follow what you are suggesting. However, if a driver connection sets an idle timeout in the DSN or settings then the connection will close on idle. If that connection (still in the pool) attempts to be used, it will return driver.ErrBadConn and the pool will try to pull another one.
Actually, it may not be a bad idea to support a method to signal to the database connection pool that the driver is bad right away rather then retrying and risk getting all bad connections. I'm not sure how that would work of hand.