go-mssqldb icon indicating copy to clipboard operation
go-mssqldb copied to clipboard

data races, rollback hangs

Open ondi opened this issue 4 years ago • 2 comments

RACE

==================
WARNING: DATA RACE
Write at 0x00c000500001 by goroutine 56:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:126 +0x71
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:758 +0x36
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous read at 0x00c000500000 by main goroutine:
  internal/race.ReadRange()
      /home/ondi/Downloads/goroot/src/internal/race/race.go:45 +0xab
  syscall.Write()
      /home/ondi/Downloads/goroot/src/syscall/syscall_unix.go:217 +0x8f
  internal/poll.(*FD).Write()
      /home/ondi/Downloads/goroot/src/internal/poll/fd_unix.go:268 +0x1f8
  net.(*netFD).Write()
      /home/ondi/Downloads/goroot/src/net/fd_unix.go:220 +0x65
  net.(*conn).Write()
      /home/ondi/Downloads/goroot/src/net/net.go:196 +0xa0
  net.(*TCPConn).Write()
      <autogenerated>:1 +0x69
  github.com/denisenkom/go-mssqldb.(*timeoutConn).Write()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/net.go:38 +0xa6
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:73 +0x2c5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 56 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c000110a30 by goroutine 56:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:127 +0x8c
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:758 +0x36
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c000110a30 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:86 +0x313
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 56 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c000110a38 by goroutine 56:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:128 +0xa6
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:758 +0x36
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c000110a38 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:87 +0x355
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 56 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c000110a39 by goroutine 56:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:129 +0xbc
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:758 +0x36
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c000110a39 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:129 +0x169
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:84 +0xb0
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 56 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c0000ec001 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:126 +0x111
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:84 +0xb0
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Previous write at 0x00c0000ec001 by goroutine 32:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:126 +0x71
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:758 +0x36
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Goroutine 32 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86b0 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:127 +0x133
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:84 +0xb0
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Previous write at 0x00c0000a86b0 by goroutine 32:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:86 +0x313
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x13a
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:759 +0x14f
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Goroutine 32 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86b8 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:128 +0x150
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:84 +0xb0
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Previous write at 0x00c0000a86b8 by goroutine 32:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:87 +0x355
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x13a
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:759 +0x14f
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Goroutine 32 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c000600008 by goroutine 15:
  internal/race.WriteRange()
      /home/ondi/Downloads/goroot/src/internal/race/race.go:49 +0x9a
  syscall.Read()
      /home/ondi/Downloads/goroot/src/syscall/syscall_unix.go:192 +0x7e
  internal/poll.(*FD).Read()
      /home/ondi/Downloads/goroot/src/internal/poll/fd_unix.go:165 +0x1c7
  net.(*netFD).Read()
      /home/ondi/Downloads/goroot/src/net/fd_unix.go:202 +0x65
  net.(*conn).Read()
      /home/ondi/Downloads/goroot/src/net/net.go:184 +0xa0
  net.(*TCPConn).Read()
      <autogenerated>:1 +0x69
  github.com/denisenkom/go-mssqldb.(*timeoutConn).Read()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/net.go:28 +0xa6
  io.ReadAtLeast()
      /home/ondi/Downloads/goroot/src/io/io.go:310 +0x98
  io.ReadFull()
      /home/ondi/Downloads/goroot/src/io/io.go:329 +0x3ee
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:152 +0x2d0
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous read at 0x00c00060000c by goroutine 24:
  runtime.slicecopy()
      /home/ondi/Downloads/goroot/src/runtime/slice.go:197 +0x0
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).Read()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:259 +0x162
  io.ReadAtLeast()
      /home/ondi/Downloads/goroot/src/io/io.go:310 +0x98
  io.ReadFull()
      /home/ondi/Downloads/goroot/src/io/io.go:329 +0x6f
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).ReadFull()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:195 +0x2f
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).uint16()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:219 +0x89
  github.com/denisenkom/go-mssqldb.parseDone()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:406 +0x6a
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:609 +0x1805

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c000600010 by goroutine 15:
  internal/race.WriteRange()
      /home/ondi/Downloads/goroot/src/internal/race/race.go:49 +0x9a
  syscall.Read()
      /home/ondi/Downloads/goroot/src/syscall/syscall_unix.go:192 +0x7e
  internal/poll.(*FD).Read()
      /home/ondi/Downloads/goroot/src/internal/poll/fd_unix.go:165 +0x1c7
  net.(*netFD).Read()
      /home/ondi/Downloads/goroot/src/net/fd_unix.go:202 +0x65
  net.(*conn).Read()
      /home/ondi/Downloads/goroot/src/net/net.go:184 +0xa0
  net.(*TCPConn).Read()
      <autogenerated>:1 +0x69
  github.com/denisenkom/go-mssqldb.(*timeoutConn).Read()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/net.go:28 +0xa6
  io.ReadAtLeast()
      /home/ondi/Downloads/goroot/src/io/io.go:310 +0x98
  io.ReadFull()
      /home/ondi/Downloads/goroot/src/io/io.go:329 +0x3ee
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:152 +0x2d0
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous read at 0x00c000600014 by goroutine 24:
  runtime.slicecopy()
      /home/ondi/Downloads/goroot/src/runtime/slice.go:197 +0x0
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).Read()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:259 +0x162
  io.ReadAtLeast()
      /home/ondi/Downloads/goroot/src/io/io.go:310 +0x98
  io.ReadFull()
      /home/ondi/Downloads/goroot/src/io/io.go:329 +0x6f
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).ReadFull()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:195 +0x2f
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).uint64()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:203 +0x8e
  github.com/denisenkom/go-mssqldb.parseDone()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:407 +0x82
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:609 +0x1805

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86d8 by goroutine 15:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:156 +0x46d
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous write at 0x00c0000a86d8 by goroutine 24:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:156 +0x46d
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86e0 by goroutine 15:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:157 +0x4b5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous write at 0x00c0000a86e0 by goroutine 24:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:157 +0x4b5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86e8 by goroutine 15:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:158 +0x503
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous write at 0x00c0000a86e8 by goroutine 24:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:158 +0x503
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c0000a86e9 by goroutine 15:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:159 +0x54b
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Previous write at 0x00c0000a86e9 by goroutine 24:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:159 +0x54b
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:164 +0xc4
  github.com/denisenkom/go-mssqldb.processSingleResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:569 +0x96

Goroutine 15 (running) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b

Goroutine 24 (finished) created at:
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:808 +0x20b
==================
==================
WARNING: DATA RACE
Write at 0x00c0000ec002 by goroutine 10:
  encoding/binary.bigEndian.PutUint16()
      /home/ondi/Downloads/goroot/src/encoding/binary/binary.go:107 +0x179
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:69 +0xb5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x13a
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:759 +0x14f
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c0000ec002 by main goroutine:
  encoding/binary.bigEndian.PutUint16()
      /home/ondi/Downloads/goroot/src/encoding/binary/binary.go:107 +0x179
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:69 +0xb5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 10 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c0000ec006 by goroutine 10:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:70 +0x220
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x13a
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:759 +0x14f
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c0000ec006 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:70 +0x220
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 10 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
==================
WARNING: DATA RACE
Write at 0x00c0000ec000 by goroutine 71:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:68 +0xa5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x13a
  github.com/denisenkom/go-mssqldb.sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tds.go:759 +0x14f
  github.com/denisenkom/go-mssqldb.(*parseResp).sendAttention()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:697 +0x6d
  github.com/denisenkom/go-mssqldb.(*parseResp).iter()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:740 +0xfd4
  github.com/denisenkom/go-mssqldb.processResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/token.go:813 +0x13f

Previous write at 0x00c0000ec000 by main goroutine:
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).flush()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:68 +0xa5
  github.com/denisenkom/go-mssqldb.(*tdsBuffer).FinishPacket()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/buf.go:134 +0x387
  github.com/denisenkom/go-mssqldb.sendRollbackXact()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/tran.go:109 +0x39c
  github.com/denisenkom/go-mssqldb.(*Conn).sendRollbackRequest()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:264 +0x1ba
  github.com/denisenkom/go-mssqldb.(*Conn).Rollback()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:251 +0x5a
  database/sql.(*Tx).rollback.func1()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2112 +0x70
  database/sql.withLock()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:3184 +0x7e
  database/sql.(*Tx).rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2111 +0xc7
  database/sql.(*Tx).Rollback()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2126 +0x1d7
  main.main()
      /home/ondi/test/test/mssql.go:63 +0x1c1

Goroutine 71 (running) created at:
  github.com/denisenkom/go-mssqldb.(*Stmt).processQueryResponse()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:600 +0x180
  github.com/denisenkom/go-mssqldb.(*Stmt).queryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:594 +0x15b
  github.com/denisenkom/go-mssqldb.(*Stmt).QueryContext()
      /home/ondi/.go/pkg/mod/github.com/denisenkom/[email protected]/mssql.go:950 +0x22a
  database/sql.ctxDriverStmtQuery()
      /home/ondi/Downloads/goroot/src/database/sql/ctxutil.go:82 +0x2c0
  database/sql.rowsiFromStatement()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2604 +0x1f8
  database/sql.(*DB).queryDC()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:1622 +0x2fd
  database/sql.(*Tx).QueryContext()
      /home/ondi/Downloads/goroot/src/database/sql/sql.go:2291 +0x1b1
  main.DoSome()
      /home/ondi/test/test/mssql.go:38 +0xee
  main.main()
      /home/ondi/test/test/mssql.go:62 +0x1c0
==================
Found 16 data race(s)
exit status 66

To Reproduce

//
// RACES
//

package main

import "log"
import "context"
import "net/url"
import "database/sql"
import _ "github.com/denisenkom/go-mssqldb"

func MsSql(username string, pass string, ip string, dbName string, dbPort string, failoverpartner string, failoverport string) (db *sql.DB, err error) {
	var conn_url url.URL
	conn_url.Scheme = "sqlserver"
	conn_url.User = url.UserPassword(username, pass)
	conn_url.Host = ip
	if len(dbPort) > 0 {
		conn_url.Host += ":" + dbPort
	}
	conn_url.Path = dbName
	values := url.Values{}
	if len(failoverpartner) > 0 {
		values.Add("failoverpartner", failoverpartner)
	}
	if len(failoverport) > 0 {
		values.Add("failoverport", failoverport)
	}
	conn_url.RawQuery = values.Encode()

	db, err = sql.Open("mssql", conn_url.String())
	return
}

func DoSome(db *sql.Tx, ctx context.Context) (err error) {
	query := "exec Some.Procedure"
	var rows *sql.Rows
	if rows, err = db.QueryContext(ctx, query); err != nil {
		log.Printf("ERROR: %v, %v", query, err)
		return
	}
	defer rows.Close()
	for rows.Next() {
		// scan some rows
	}
	return
}

func main() {
	db, err := MsSql("username", "pass", "ip", "dbName", "1433", "failoverpartner", "1433")
	if err != nil {
		log.Printf("CONNECT: %v", err)
		return
	}
	for i := 0; i < 100; i++ {
		ctx := context.Background()
		tx, err := db.BeginTx(ctx, nil)
		if err != nil {
			log.Printf("TX: %v", err)
			return
		}
		DoSome(tx, ctx)
		tx.Rollback()
	}
}

Expected behavior a 100 rollback's with no errors and races

Further technical details

SQL Server version: SQL Server 2017 Operating system: Fedora 32 under WSL2 go version: go version devel +6917529cc6 Sat Feb 15 16:40:12 2020 +0000 linux/amd64

ondi avatar Feb 18 '20 17:02 ondi

Thanks for bringing this to our attention.

chris-rossi avatar Feb 19 '20 18:02 chris-rossi

v0.10.0 fixed a similar issue for me, so that one could be rechecked.

AlekSi avatar Aug 27 '21 09:08 AlekSi