• Chris Hines's avatar
    database/sql: avoid deadlock waiting for connections · 6de40099
    Chris Hines authored
    Previously with db.maxOpen > 0, db.maxOpen+n failed connection attempts
    started concurrently could result in a deadlock. DB.conn and
    DB.openNewConnection did not trigger the DB.connectionOpener go routine
    after a failed connection attempt. This omission could leave go routines
    waiting for DB.connectionOpener forever.
    
    In addition the logic to track the state of the pool was inconsistent.
    db.numOpen was sometimes incremented optimistically and sometimes not.
    This change harmonizes the logic and eliminates the db.pendingOpens
    variable, making the logic easier to understand and maintain.
    
    Fixes #10886
    
    Change-Id: I983c4921a3dacfbd531c3d7f8d2da8a592e9922a
    Reviewed-on: https://go-review.googlesource.com/14547Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    6de40099
Name
Last commit
Last update
..
sql Loading commit data...