Skip to content

Commit 1cc8336

Browse files
committed
Revert "Fix checking cancelled connections back into the connection pool (go-sql-driver#1095)"
This reverts commit 6313f20.
1 parent 8e3eb81 commit 1cc8336

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,3 @@ Multiplay Ltd.
114114
Percona LLC
115115
Pivotal Inc.
116116
Stripe Inc.
117-
Zendesk Inc.

connection.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,6 @@ func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
472472

473473
// BeginTx implements driver.ConnBeginTx interface
474474
func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
475-
if mc.closed.IsSet() {
476-
return nil, driver.ErrBadConn
477-
}
478-
479475
if err := mc.watchCancel(ctx); err != nil {
480476
return nil, err
481477
}

driver_test.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,12 +2621,7 @@ func TestContextCancelBegin(t *testing.T) {
26212621
runTests(t, dsn, func(dbt *DBTest) {
26222622
dbt.mustExec("CREATE TABLE test (v INTEGER)")
26232623
ctx, cancel := context.WithCancel(context.Background())
2624-
conn, err := dbt.db.Conn(ctx)
2625-
if err != nil {
2626-
dbt.Fatal(err)
2627-
}
2628-
defer conn.Close()
2629-
tx, err := conn.BeginTx(ctx, nil)
2624+
tx, err := dbt.db.BeginTx(ctx, nil)
26302625
if err != nil {
26312626
dbt.Fatal(err)
26322627
}
@@ -2656,17 +2651,7 @@ func TestContextCancelBegin(t *testing.T) {
26562651
dbt.Errorf("expected sql.ErrTxDone or context.Canceled, got %v", err)
26572652
}
26582653

2659-
// The connection is now in an inoperable state - so performing other
2660-
// operations should fail with ErrBadConn
2661-
// Important to exercise isolation level too - it runs SET TRANSACTION ISOLATION
2662-
// LEVEL XXX first, which needs to return ErrBadConn if the connection's context
2663-
// is cancelled
2664-
_, err = conn.BeginTx(context.Background(), &sql.TxOptions{Isolation: sql.LevelReadCommitted})
2665-
if err != driver.ErrBadConn {
2666-
dbt.Errorf("expected driver.ErrBadConn, got %v", err)
2667-
}
2668-
2669-
// cannot begin a transaction (on a different conn) with a canceled context
2654+
// Context is canceled, so cannot begin a transaction.
26702655
if _, err := dbt.db.BeginTx(ctx, nil); err != context.Canceled {
26712656
dbt.Errorf("expected context.Canceled, got %v", err)
26722657
}

0 commit comments

Comments
 (0)