Skip to content

Commit

Permalink
database/sql: fix TestTxStmtDeadlock test
Browse files Browse the repository at this point in the history
Drop error check because errors can be
not only ErrTxDone for tx stmt executions,
and the purpose of the test is just reproducing
deadlock.

Fixes #42259

Change-Id: I9e7105ada1403ec7064dcc1c3385b36893a1c195
Reviewed-on: https://go-review.googlesource.com/c/go/+/266097
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
  • Loading branch information
tz70s authored and odeke-em committed Oct 29, 2020
1 parent c1afbf6 commit d8044a6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/database/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2828,12 +2828,10 @@ func TestTxStmtDeadlock(t *testing.T) {
}
// Run number of stmt queries to reproduce deadlock from context cancel
for i := 0; i < 1e3; i++ {
// Encounter any close related errors (e.g. ErrTxDone, stmt is closed)
// is expected due to context cancel.
_, err = stmt.Query(1)
if err != nil {
// Encounter ErrTxDone here is expected due to context cancel
if err != ErrTxDone {
t.Fatalf("unexpected error while executing stmt, err: %v", err)
}
break
}
}
Expand Down

0 comments on commit d8044a6

Please sign in to comment.