-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Issue description
-
I know concurrency query in one transaction is not allowed,it will report error "busy buffer".But i want to confirm that is concurrency exec in one transaction is correct or allowed? I have done some tests and concurrency exec works fine
-
According to database/sql doc,

But when i do concurrency query in one Stmt,the same error occurs:"busy buffer".
So,what's the correct way to use Stmt ...
Example code
tx, err := db.Begin()
if err != nil {
t.Fatal(err)
}
defer tx.Rollback()
stmt, err := tx.Prepare("select id from lnmp where id in (?,?,?,?,?,?,?)")
if err != nil {
t.Fatal(err)
}
defer stmt.Close()
var wg sync.WaitGroup
for i := 1; i < 10; i++ {
i := i
wg.Add(1)
go func() {
defer wg.Done()
rows, err := stmt.Query(i, i+1, i+2, i+3,i+4,i+5,i+6)
if err != nil {
t.Logf("stmt query error:%v", err)
return
}
defer rows.Close()
for rows.Next() {
var id int
rows.Scan(&id)
}
}()
}
wg.Wait()Configuration
Driver version (or git SHA):
1.4.0
Go version: run go version in your console
1.13
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL 5.7
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
mac os 10.15.5
Metadata
Metadata
Assignees
Labels
No labels
