• INADA Naoki's avatar
    database/sql: Add DB.SetConnMaxLifetime · 0c516c16
    INADA Naoki authored
    Long lived connections may make some DB operation difficult.
    (e.g. retiring load balanced DB server.)
    So SetConnMaxLifetime closes long lived connections.
    
    It can be used to limit maximum idle time, too.
    Closing idle connections reduces active connections while application is idle
    and avoids connections are closed by server side (cause errBadConn while querying).
    
    fixes #9851
    
    Change-Id: I2e8e824219c1bee7f4b885d38ed96d11b7202b56
    Reviewed-on: https://go-review.googlesource.com/6580
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    0c516c16
sql_test.go 52.4 KB