Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/sql: possible race condition when canceling Tx with open Rows #20622

Closed
kardianos opened this issue Jun 9, 2017 · 4 comments
Closed

database/sql: possible race condition when canceling Tx with open Rows #20622

kardianos opened this issue Jun 9, 2017 · 4 comments
Assignees
Milestone

Comments

@kardianos
Copy link
Contributor

@kardianos kardianos commented Jun 9, 2017

The following program produces a race condition for both mysql and sqlserver drivers. While this could be a common issue with both drivers, it is also possible it is an issue with database/sql.

To reproduce:

package main

import (
	"context"
	"database/sql"
	"flag"
	"fmt"
	"time"

	_ "github.com/denisenkom/go-mssqldb"
	_ "github.com/go-sql-driver/mysql"
	"github.com/golang/glog"
)

var (
	driverFlag = flag.String("driver", "mysql", "SQL Driver Name")
	dbFlag     = flag.String("dsn", "", "DSN")
)

func main() {
	flag.Parse()
	ctx, cancel := context.WithCancel(context.Background())
	db, err := sql.Open(*driverFlag, *dbFlag)
	if err != nil {
		glog.Exitf("failed to Open(%q): %v", *dbFlag, err)
	}
	defer db.Close()

	tx, err := db.BeginTx(ctx, nil)
	if err != nil {
		glog.Exitf("failed to BeginTx(): %v", err)
	}

	sql1 := `declare @vv table(ID bigint primary key identity(1,1), Item int);

insert into @vv (Item)
SELECT n = ones.n + 10*tens.n
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),
	 (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) tens(n)
where 1=1
	and ones.n + 10*tens.n between 10 and 100
ORDER BY 1;

select * from @vv;`

	sql2 := `SELECT id, val FROM test;`

	sqlUse := sql2
	if *driverFlag == "sqlserver" {
		sqlUse = sql1
	}

	rows, err := tx.Query(sqlUse)
	if err != nil {
		glog.Exitf("failed to Query(): %v", err)
	}

	count := 0
	for rows.Next() {
		count++
		var val2, val3 int64
		if err := rows.Scan(&val2, &val3); err != nil {
			glog.Exitf("failed to Scan(): %v", err)
		}
		fmt.Printf("%d %d\n", val2, val3)

		if count == 1 {
			glog.Errorf("cancel the context out from under the transaction!")
			cancel()
		}
		time.Sleep(100 * time.Millisecond)
	}
	rows.Close()
	tx.Commit()
}

Race report using sqlserver driver

==================
WARNING: DATA RACE
Write at 0x00c420278148 by goroutine 22:
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:127 +0x215
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:645 +0x64
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:688 +0xa81
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:761 +0x16b

Previous write at 0x00c420278148 by goroutine 21:
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:127 +0x29d
  github.com/denisenkom/go-mssqldb.(*MssqlConn).sendRollbackRequest()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:112 +0x42f
  github.com/denisenkom/go-mssqldb.(*MssqlConn).Rollback()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:101 +0x3c
  database/sql.(*Tx).rollback.func1()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1767 +0x6e
  database/sql.withLock()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2814 +0x76
  database/sql.(*Tx).rollback()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1766 +0x10a
  database/sql.(*Tx).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1678 +0x7d

Goroutine 22 (running) created at:
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).processQueryResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:328 +0x11e
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).queryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:322 +0xe5
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).QueryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql_go18.go:66 +0x241
  database/sql.ctxDriverStmtQuery()
      /home/daniel/code/go-cl/src/database/sql/ctxutil.go:83 +0x2e8
  database/sql.rowsiFromStatement()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2256 +0x29d
  database/sql.(*DB).queryDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1333 +0x387
  database/sql.(*Tx).QueryContext()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1963 +0x1da
  database/sql.(*Tx).Query()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1968 +0xa8
  main.main()
      /home/daniel/src/test/trillian617/main.go:61 +0x3e8

Goroutine 21 (running) created at:
  database/sql.(*DB).beginDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1428 +0x359
  database/sql.(*DB).begin()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1403 +0x130
  database/sql.(*DB).BeginTx()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1381 +0xa3
  main.main()
      /home/daniel/src/test/trillian617/main.go:37 +0x2bd
==================
==================
WARNING: DATA RACE
Read at 0x00c4202bc000 by goroutine 21:
  runtime.slicecopy()
      /home/daniel/code/go-cl/src/runtime/slice.go:160 +0x0
  crypto/tls.(*Conn).writeRecordLocked()
      /home/daniel/code/go-cl/src/crypto/tls/conn.go:907 +0x44a
  crypto/tls.(*Conn).Write()
      /home/daniel/code/go-cl/src/crypto/tls/conn.go:1068 +0x236
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:76 +0x213
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:132 +0x80
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/tran.go:110 +0x446
  github.com/denisenkom/go-mssqldb.(*MssqlConn).sendRollbackRequest()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:112 +0x42f
  github.com/denisenkom/go-mssqldb.(*MssqlConn).Rollback()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:101 +0x3c
  database/sql.(*Tx).rollback.func1()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1767 +0x6e
  database/sql.withLock()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2814 +0x76
  database/sql.(*Tx).rollback()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1766 +0x10a
  database/sql.(*Tx).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1678 +0x7d

Previous write at 0x00c4202bc004 by goroutine 22:
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:123 +0x108
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:645 +0x64
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:688 +0xa81
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:761 +0x16b

Goroutine 21 (running) created at:
  database/sql.(*DB).beginDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1428 +0x359
  database/sql.(*DB).begin()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1403 +0x130
  database/sql.(*DB).BeginTx()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1381 +0xa3
  main.main()
      /home/daniel/src/test/trillian617/main.go:37 +0x2bd

Goroutine 22 (running) created at:
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).processQueryResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:328 +0x11e
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).queryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:322 +0xe5
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).QueryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql_go18.go:66 +0x241
  database/sql.ctxDriverStmtQuery()
      /home/daniel/code/go-cl/src/database/sql/ctxutil.go:83 +0x2e8
  database/sql.rowsiFromStatement()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2256 +0x29d
  database/sql.(*DB).queryDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1333 +0x387
  database/sql.(*Tx).QueryContext()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1963 +0x1da
  database/sql.(*Tx).Query()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1968 +0xa8
  main.main()
      /home/daniel/src/test/trillian617/main.go:61 +0x3e8
==================
==================
WARNING: DATA RACE
Write at 0x00c4202bc001 by goroutine 22:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:131 +0x60
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/tds.go:653 +0x229
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:645 +0x64
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:688 +0xa81
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:761 +0x16b

Previous write at 0x00c4202bc001 by goroutine 21:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:131 +0x60
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/tran.go:110 +0x446
  github.com/denisenkom/go-mssqldb.(*MssqlConn).sendRollbackRequest()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:112 +0x42f
  github.com/denisenkom/go-mssqldb.(*MssqlConn).Rollback()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:101 +0x3c
  database/sql.(*Tx).rollback.func1()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1767 +0x6e
  database/sql.withLock()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2814 +0x76
  database/sql.(*Tx).rollback()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1766 +0x10a
  database/sql.(*Tx).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1678 +0x7d

Goroutine 22 (running) created at:
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).processQueryResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:328 +0x11e
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).queryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql.go:322 +0xe5
  github.com/denisenkom/go-mssqldb.(*MssqlStmt).QueryContext()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/mssql_go18.go:66 +0x241
  database/sql.ctxDriverStmtQuery()
      /home/daniel/code/go-cl/src/database/sql/ctxutil.go:83 +0x2e8
  database/sql.rowsiFromStatement()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2256 +0x29d
  database/sql.(*DB).queryDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1333 +0x387
  database/sql.(*Tx).QueryContext()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1963 +0x1da
  database/sql.(*Tx).Query()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1968 +0xa8
  main.main()
      /home/daniel/src/test/trillian617/main.go:61 +0x3e8

Goroutine 21 (running) created at:
  database/sql.(*DB).beginDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1428 +0x359
  database/sql.(*DB).begin()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1403 +0x130
  database/sql.(*DB).BeginTx()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1381 +0xa3
  main.main()
      /home/daniel/src/test/trillian617/main.go:37 +0x2bd
==================
==================
WARNING: DATA RACE
Write at 0x00c4202bd008 by goroutine 27:
  runtime.slicecopy()
      /home/daniel/code/go-cl/src/runtime/slice.go:160 +0x0
  crypto/tls.(*Conn).Read()
      /home/daniel/code/go-cl/src/crypto/tls/conn.go:503 +0x377
  io.ReadAtLeast()
      /home/daniel/code/go-cl/src/io/io.go:307 +0x93
  io.ReadFull()
      /home/daniel/code/go-cl/src/io/io.go:325 +0x72
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:149 +0x448
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:161 +0x3c
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:531 +0xdd

Previous read at 0x00c4202bd008 by goroutine 26:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).ReadByte()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:178 +0xb5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).byte()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/buf.go:184 +0x38
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:545 +0x1ac

Goroutine 27 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:756 +0x201

Goroutine 26 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/daniel/src/github.com/denisenkom/go-mssqldb/token.go:756 +0x201
==================
Found 4 data race(s)

Race report using the mysql driver

==================
WARNING: DATA RACE
Write at 0x00c4200b4030 by goroutine 10:
  github.com/go-sql-driver/mysql.(*buffer).readNext()
      /home/daniel/src/github.com/go-sql-driver/mysql/buffer.go:104 +0xf5
  github.com/go-sql-driver/mysql.(*mysqlConn).readPacket()
      /home/daniel/src/github.com/go-sql-driver/mysql/packets.go:31 +0xd4
  github.com/go-sql-driver/mysql.(*mysqlConn).readUntilEOF()
      /home/daniel/src/github.com/go-sql-driver/mysql/packets.go:768 +0x50
  github.com/go-sql-driver/mysql.(*mysqlRows).Close()
      /home/daniel/src/github.com/go-sql-driver/mysql/rows.go:67 +0x7d
  github.com/go-sql-driver/mysql.(*textRows).Close()
      <autogenerated>:1 +0x43
  database/sql.(*Rows).close()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2703 +0x15b
  database/sql.(*Rows).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2391 +0x14c

Previous read at 0x00c4200b4030 by goroutine 9:
  github.com/go-sql-driver/mysql.(*mysqlConn).writeCommandPacketStr()
      /home/daniel/src/github.com/go-sql-driver/mysql/buffer.go:113 +0x73
  github.com/go-sql-driver/mysql.(*mysqlConn).exec()
      /home/daniel/src/github.com/go-sql-driver/mysql/connection.go:292 +0x55
  github.com/go-sql-driver/mysql.(*mysqlTx).Rollback()
      /home/daniel/src/github.com/go-sql-driver/mysql/transaction.go:28 +0xfb
  database/sql.(*Tx).rollback.func1()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1767 +0x6e
  database/sql.withLock()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2814 +0x76
  database/sql.(*Tx).rollback()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1766 +0x10a
  database/sql.(*Tx).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1678 +0x7d

Goroutine 10 (running) created at:
  database/sql.(*Rows).initContextClose()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2375 +0xdd
  database/sql.(*DB).queryDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1317 +0xb7f
  database/sql.(*Tx).QueryContext()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1963 +0x1da
  database/sql.(*Tx).Query()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1968 +0xa8
  main.main()
      /home/daniel/src/test/trillian617/main.go:40 +0x389

Goroutine 9 (running) created at:
  database/sql.(*DB).beginDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1428 +0x359
  database/sql.(*DB).begin()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1403 +0x130
  database/sql.(*DB).BeginTx()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1381 +0xa3
  main.main()
      /home/daniel/src/test/trillian617/main.go:35 +0x297
==================
==================
WARNING: DATA RACE
Read at 0x00c4200b4086 by goroutine 10:
  github.com/go-sql-driver/mysql.(*mysqlConn).readPacket()
      /home/daniel/src/github.com/go-sql-driver/mysql/packets.go:42 +0x1bd
  github.com/go-sql-driver/mysql.(*mysqlConn).readUntilEOF()
      /home/daniel/src/github.com/go-sql-driver/mysql/packets.go:768 +0x50
  github.com/go-sql-driver/mysql.(*mysqlRows).Close()
      /home/daniel/src/github.com/go-sql-driver/mysql/rows.go:67 +0x7d
  github.com/go-sql-driver/mysql.(*textRows).Close()
      <autogenerated>:1 +0x43
  database/sql.(*Rows).close()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2703 +0x15b
  database/sql.(*Rows).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2391 +0x14c

Previous write at 0x00c4200b4086 by goroutine 9:
  github.com/go-sql-driver/mysql.(*mysqlConn).writeCommandPacketStr()
      /home/daniel/src/github.com/go-sql-driver/mysql/packets.go:425 +0x57
  github.com/go-sql-driver/mysql.(*mysqlConn).exec()
      /home/daniel/src/github.com/go-sql-driver/mysql/connection.go:292 +0x55
  github.com/go-sql-driver/mysql.(*mysqlTx).Rollback()
      /home/daniel/src/github.com/go-sql-driver/mysql/transaction.go:28 +0xfb
  database/sql.(*Tx).rollback.func1()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1767 +0x6e
  database/sql.withLock()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2814 +0x76
  database/sql.(*Tx).rollback()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1766 +0x10a
  database/sql.(*Tx).awaitDone()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1678 +0x7d

Goroutine 10 (running) created at:
  database/sql.(*Rows).initContextClose()
      /home/daniel/code/go-cl/src/database/sql/sql.go:2375 +0xdd
  database/sql.(*DB).queryDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1317 +0xb7f
  database/sql.(*Tx).QueryContext()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1963 +0x1da
  database/sql.(*Tx).Query()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1968 +0xa8
  main.main()
      /home/daniel/src/test/trillian617/main.go:40 +0x389

Goroutine 9 (running) created at:
  database/sql.(*DB).beginDC()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1428 +0x359
  database/sql.(*DB).begin()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1403 +0x130
  database/sql.(*DB).BeginTx()
      /home/daniel/code/go-cl/src/database/sql/sql.go:1381 +0xa3
  main.main()
      /home/daniel/src/test/trillian617/main.go:35 +0x297
==================

orig from google/trillian#617

@kardianos kardianos added this to the Go1.9 milestone Jun 9, 2017
@kardianos kardianos self-assigned this Jun 9, 2017
@bradfitz bradfitz added the NeedsFix label Jun 9, 2017
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jun 9, 2017

We want to do a beta early next week. Can you get a fix out soon?

@kardianos
Copy link
Contributor Author

@kardianos kardianos commented Jun 9, 2017

I should be able to look into it this afternoon.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 11, 2017

CL https://golang.org/cl/45275 mentions this issue.

@kardianos
Copy link
Contributor Author

@kardianos kardianos commented Jun 11, 2017

After instrumenting the fakeConn with a var that gets read and written to on each call, the concurrency test blew up on the race try bot, though I'm having trouble replicating it locally. This was after I fixed the above sql interface race.
https://storage.googleapis.com/go-build-log/495e96e8/linux-amd64-race_7e99dc4a.log

==================
WARNING: DATA RACE
Read at 0x00c4202869d0 by goroutine 145:
  database/sql.(*rowsCursor).Next()
      /tmp/workdir/go/src/database/sql/fakedb_test.go:958 +0x15d
  database/sql.(*Rows).nextLocked()
      /tmp/workdir/go/src/database/sql/sql.go:2418 +0xd1
  database/sql.(*Rows).Next.func1()
      /tmp/workdir/go/src/database/sql/sql.go:2403 +0x57
  database/sql.withLock()
      /tmp/workdir/go/src/database/sql/sql.go:2816 +0x76
  database/sql.(*Rows).Next()
      /tmp/workdir/go/src/database/sql/sql.go:2402 +0xe8
  database/sql.(*concurrentTxStmtQueryTest).test()
      /tmp/workdir/go/src/database/sql/sql_test.go:2939 +0x14e
  database/sql.doConcurrentTest.func1()
      /tmp/workdir/go/src/database/sql/sql_test.go:3039 +0x7c

Previous write at 0x00c4202869d0 by goroutine 99:
  database/sql.(*fakeStmt).QueryContext()
      /tmp/workdir/go/src/database/sql/fakedb_test.go:773 +0x2e0
  database/sql.ctxDriverStmtQuery()
      /tmp/workdir/go/src/database/sql/ctxutil.go:83 +0x2e8
  database/sql.rowsiFromStatement()
      /tmp/workdir/go/src/database/sql/sql.go:2256 +0x29d
  database/sql.(*Stmt).QueryContext()
      /tmp/workdir/go/src/database/sql/sql.go:2194 +0x28b
  database/sql.(*Stmt).Query()
      /tmp/workdir/go/src/database/sql/sql.go:2232 +0x88
  database/sql.(*concurrentTxStmtQueryTest).test()
      /tmp/workdir/go/src/database/sql/sql_test.go:2932 +0x79
  database/sql.doConcurrentTest.func1()
      /tmp/workdir/go/src/database/sql/sql_test.go:3039 +0x7c

Goroutine 145 (running) created at:
  database/sql.doConcurrentTest()
      /tmp/workdir/go/src/database/sql/sql_test.go:3037 +0x2bd
  database/sql.TestConcurrency()
      /tmp/workdir/go/src/database/sql/sql_test.go:3241 +0x1ee
  testing.tRunner()
      /tmp/workdir/go/src/testing/testing.go:747 +0x16c

Goroutine 99 (running) created at:
  database/sql.doConcurrentTest()
      /tmp/workdir/go/src/database/sql/sql_test.go:3037 +0x2bd
  database/sql.TestConcurrency()
      /tmp/workdir/go/src/database/sql/sql_test.go:3241 +0x1ee
  testing.tRunner()
      /tmp/workdir/go/src/testing/testing.go:747 +0x16c
==================
==================
WARNING: DATA RACE
Read at 0x00c4202869d0 by goroutine 14:
  database/sql.(*rowsCursor).Next()
      /tmp/workdir/go/src/database/sql/fakedb_test.go:958 +0x15d
  database/sql.(*Rows).nextLocked()
      /tmp/workdir/go/src/database/sql/sql.go:2418 +0xd1
  database/sql.(*Rows).Next.func1()
      /tmp/workdir/go/src/database/sql/sql.go:2403 +0x57
  database/sql.withLock()
      /tmp/workdir/go/src/database/sql/sql.go:2816 +0x76
  database/sql.(*Rows).Next()
      /tmp/workdir/go/src/database/sql/sql.go:2402 +0xe8
  database/sql.(*concurrentTxStmtQueryTest).test()
      /tmp/workdir/go/src/database/sql/sql_test.go:2939 +0x14e
  database/sql.doConcurrentTest.func1()
      /tmp/workdir/go/src/database/sql/sql_test.go:3039 +0x7c

Previous write at 0x00c4202869d0 by goroutine 99:
  database/sql.(*fakeStmt).QueryContext()
      /tmp/workdir/go/src/database/sql/fakedb_test.go:773 +0x2e0
  database/sql.ctxDriverStmtQuery()
      /tmp/workdir/go/src/database/sql/ctxutil.go:83 +0x2e8
  database/sql.rowsiFromStatement()
      /tmp/workdir/go/src/database/sql/sql.go:2256 +0x29d
  database/sql.(*Stmt).QueryContext()
      /tmp/workdir/go/src/database/sql/sql.go:2194 +0x28b
  database/sql.(*Stmt).Query()
      /tmp/workdir/go/src/database/sql/sql.go:2232 +0x88
  database/sql.(*concurrentTxStmtQueryTest).test()
      /tmp/workdir/go/src/database/sql/sql_test.go:2932 +0x79
  database/sql.doConcurrentTest.func1()
      /tmp/workdir/go/src/database/sql/sql_test.go:3039 +0x7c

Goroutine 14 (running) created at:
  database/sql.doConcurrentTest()
      /tmp/workdir/go/src/database/sql/sql_test.go:3037 +0x2bd
  database/sql.TestConcurrency()
      /tmp/workdir/go/src/database/sql/sql_test.go:3241 +0x1ee
  testing.tRunner()
      /tmp/workdir/go/src/testing/testing.go:747 +0x16c

Goroutine 99 (running) created at:
  database/sql.doConcurrentTest()
      /tmp/workdir/go/src/database/sql/sql_test.go:3037 +0x2bd
  database/sql.TestConcurrency()
      /tmp/workdir/go/src/database/sql/sql_test.go:3241 +0x1ee
  testing.tRunner()
      /tmp/workdir/go/src/testing/testing.go:747 +0x16c
==================
--- FAIL: TestConcurrency (0.07s)
	testing.go:700: race detected during execution of test
@gopherbot gopherbot closed this in b0d592c Jun 12, 2017
@golang golang locked and limited conversation to collaborators Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.