mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
3820191839
commit
b0d592c3c9
3 changed files with 85 additions and 12 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue