aboutsummaryrefslogtreecommitdiff
path: root/src/database/sql/sql.go
diff options
context:
space:
mode:
authorDaniel Theophanes <kardianos@gmail.com>2017-06-10 22:02:53 -0700
committerDaniel Theophanes <kardianos@gmail.com>2017-06-12 15:53:00 +0000
commitb0d592c3c9a356b661c2d6bb958528f2761d821e (patch)
tree61aa35318e1eb50f82fcb49fcbd09a78046d631a /src/database/sql/sql.go
parent3820191839a5b87acab5106b5fb43113d4f18b08 (diff)
downloadgo-b0d592c3c9a356b661c2d6bb958528f2761d821e.tar.xz
database/sql: prevent race on Rows close with Tx Rollback
In addition to adding a guard to the Rows close, add a var in the fakeConn that gets read and written to on each operation, simulating writing or reading from the server. TestConcurrency/TxStmt* tests have been commented out as they now fail after checking for races on the fakeConn. See issue #20646 for more information. Fixes #20622 Change-Id: I80b36ea33d776e5b4968be1683ff8c61728ee1ea Reviewed-on: https://go-review.googlesource.com/45275 Run-TryBot: Daniel Theophanes <kardianos@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/database/sql/sql.go')
-rw-r--r--src/database/sql/sql.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
index f7919f983c..aa254b87a1 100644
--- a/src/database/sql/sql.go
+++ b/src/database/sql/sql.go
@@ -2700,7 +2700,9 @@ func (rs *Rows) close(err error) error {
rs.lasterr = err
}
- err = rs.rowsi.Close()
+ withLock(rs.dc, func() {
+ err = rs.rowsi.Close()
+ })
if fn := rowsCloseHook(); fn != nil {
fn(rs, &err)
}