From ed7888aea6021e25b0ea58bcad3f26da2b139432 Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Wed, 22 Apr 2020 12:45:44 -0700 Subject: database/sql: de-flake TestTxCannotCommitAfterRollback Do not cancel rows during test. Only cancel the Tx. Correct the referenced issue number on the test. Fixes #38597 Change-Id: I0e8ba1bf2a8ba638d121c9c6938501fec1d5e961 Reviewed-on: https://go-review.googlesource.com/c/go/+/229478 Run-TryBot: Daniel Theophanes TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/database/sql/sql.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/database/sql/sql.go') diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 6e31714445..374dd98b00 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -2793,10 +2793,17 @@ func (rs *Rows) lasterrOrErrLocked(err error) error { return err } +// bypassRowsAwaitDone is only used for testing. +// If true, it will not close the Rows automatically from the context. +var bypassRowsAwaitDone = false + func (rs *Rows) initContextClose(ctx, txctx context.Context) { if ctx.Done() == nil && (txctx == nil || txctx.Done() == nil) { return } + if bypassRowsAwaitDone { + return + } ctx, rs.cancel = context.WithCancel(ctx) go rs.awaitDone(ctx, txctx) } -- cgit v1.3