• Daniel Theophanes's avatar
    database/sql: ensure all driver interfaces are called under single lock · 1126d148
    Daniel Theophanes authored
    Russ pointed out in a previous CL golang.org/cl/65731 that not only
    was the locking incomplete, previous changes did not correctly
    lock driver calls in other sections. After inspecting
    driverConn, driverStmt, driverResult, Tx, and Rows structs
    where driver interfaces are stored, I discovered a few more places
    that failed to lock driver calls. The largest of these
    was the parameter type converter "driverArgs".
    
    driverArgs was typically called right before another call to the
    driver in a locked region, so I made the entire driverArgs expect
    a locked driver mutex and combined the region. This should not
    be a problem because the connection is pulled out of the connection
    pool either way so there shouldn't be contention.
    
    Fixes #21117
    
    Change-Id: I88d46f74dca25fb11a30f0bf8e79785a73133d23
    Reviewed-on: https://go-review.googlesource.com/71433
    Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    1126d148
convert_test.go 14.7 KB