go/src/database/sql
Daniel Theophanes 44f9a3566c database/sql: fix deadlock test in prepare statement
The issue go#46783 correctly diagnosed the context timeout
caused an intermittent failure when the context was canceled
prior to the BeginTx call. However due to the asynchronous nature
of canceling a Tx through a context on fast systems, the tx.Prepare
also succeeded. On slower systems or if a time.Sleep was inserted
between the BeginTx and Prepare, the Prepare would fail.

Resolve this by moving the context cancel after the Prepare.
This will still trigger the deadlock which I tested locally.
In addition, I interspersed multiple time.Sleep calls and the
test still functioned.

Fixes #46852

Change-Id: I9cbf90d3c12b2555493a37799738772b615ae39d
Reviewed-on: https://go-review.googlesource.com/c/go/+/329830
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
2021-06-21 17:37:23 +00:00
..
driver database/sql: close driver.Connector if it implements io.Closer 2021-02-25 19:34:27 +00:00
convert.go
convert_test.go
ctxutil.go
doc.txt
example_cli_test.go
example_service_test.go
example_test.go database/sql: fix incorrect function name in example_test 2020-04-28 14:05:09 +00:00
fakedb_test.go database/sql: add NullInt16 and NullByte 2021-05-04 17:31:29 +00:00
sql.go database/sql: add NullInt16 and NullByte 2021-05-04 17:31:29 +00:00
sql_test.go database/sql: fix deadlock test in prepare statement 2021-06-21 17:37:23 +00:00