From 1126d1483f0397648905fcd4590ae45352cabd69 Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Tue, 17 Oct 2017 15:59:56 -0700 Subject: database/sql: ensure all driver interfaces are called under single lock 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 TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/database/sql/convert_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/database/sql/convert_test.go') diff --git a/src/database/sql/convert_test.go b/src/database/sql/convert_test.go index 35dbab3339..c198177760 100644 --- a/src/database/sql/convert_test.go +++ b/src/database/sql/convert_test.go @@ -481,7 +481,7 @@ func TestDriverArgs(t *testing.T) { } for i, tt := range tests { ds := &driverStmt{Locker: &sync.Mutex{}, si: stubDriverStmt{nil}} - got, err := driverArgs(nil, ds, tt.args) + got, err := driverArgsConnLocked(nil, ds, tt.args) if err != nil { t.Errorf("test[%d]: %v", i, err) continue -- cgit v1.3