]> Cypherpunks repositories - gostls13.git/commitdiff
database/sql: fix TestTxStmtDeadlock test
authorTzu-Chiao Yeh <su3g4284zo6y7@gmail.com>
Wed, 28 Oct 2020 22:03:08 +0000 (06:03 +0800)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Thu, 29 Oct 2020 00:19:20 +0000 (00:19 +0000)
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>

src/database/sql/sql_test.go

index 8ae6e1339e18f45f57deabd8e0c1954ba8460c96..4b02657b7e2bf91d0ac1d622850aee691dc30c40 100644 (file)
@@ -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
                }
        }