diff options
| author | Daniel Theophanes <kardianos@gmail.com> | 2017-09-23 15:30:46 -0700 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2017-10-13 18:11:41 +0000 |
| commit | 897080d5cbb1793f8ad3ef5fb7c6fafba2e97d42 (patch) | |
| tree | 72ae4bc21424894d2b6cada8be141d7e48856972 /src/database/sql/fakedb_test.go | |
| parent | 350b74bc4b9f37ba29ef02c2f89d687ae8563a05 (diff) | |
| download | go-897080d5cbb1793f8ad3ef5fb7c6fafba2e97d42.tar.xz | |
database/sql: prevent race in driver by locking dc in Next
Database drivers should be called from a single goroutine to ease
driver's design. If a driver chooses to handle context
cancels internally it may do so.
The sql package violated this agreement when calling Next or
NextResultSet. It was possible for a concurrent rollback
triggered from a context cancel to call a Tx.Rollback (which
takes a driver connection lock) while a Rows.Next is in progress
(which does not tack the driver connection lock).
The current internal design of the sql package is each call takes
roughly two locks: a closemu lock which prevents an disposing of
internal resources (assigning nil or removing from lists)
and a driver connection lock that prevents calling driver code from
multiple goroutines.
Fixes #21117
Change-Id: Ie340dc752a503089c27f57ffd43e191534829360
Reviewed-on: https://go-review.googlesource.com/65731
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/database/sql/fakedb_test.go')
| -rw-r--r-- | src/database/sql/fakedb_test.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go index 4dcd096ca4..8e77df4ace 100644 --- a/src/database/sql/fakedb_test.go +++ b/src/database/sql/fakedb_test.go @@ -943,6 +943,7 @@ type rowsCursor struct { } func (rc *rowsCursor) touchMem() { + rc.parentMem.touchMem() rc.line++ } |
