Description
This error occurs in a benchmark program with driver version v1.8.1 against a 8.0.40 MySQL server. There is a similar issue in #1393, but I believe this is different.
My test program issues concurrent large LOAD DATA INFILE
requests to measure sustained bulk insert rates, and it generally works well, but occasionally I get the following error:
[mysql] 2025/01/28 20:36:44 connection.go:49: busy buffer
err:[inserts commands out of sync. Did you run multiple statements at once?]
During the DB open, we issue the following:
const maxConns = 64
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxOpenConns(maxConns)
db.SetMaxIdleConns(maxConns)
The only call made on the returned db is the following, which is made continuously in multiple (64) goroutines. As far as I know, it should be legal to issue these calls concurrently against a single *sql.DB struct.
sql := fmt.Sprintf("LOAD DATA LOCAL INFILE '%v' INTO TABLE movements COLUMNS TERMINATED BY ',';", filename)
res, err := db.ExecContext(ctx, sql)
if err != nil {
return err
}
numRows, err := res.RowsAffected()
if err != nil {
return err
}
My server has wait_timeout = 28800
. On the last occasion, the error occurred 2600 seconds into the benchmark run (not 26,000, so only 10% of the wait_timeout). So I don't believe this should be caused by the server closing the connections from inactivity. I have 64 goroutines calling continuously on a db with 64 max connections, so I wouldn't think any are idle, anyway.
Activity
methane commentedon Jan 30, 2025
Please try master branch and tcpdump.
DaLinR commentedon Mar 6, 2025
@methane Hello, my version is v1.7.0 and it's hard to use tcpdump in our development env.
I also noticed that if I don't set the ConnMaxLifetime and ConnMaxIdleTime configurations, there will be no problem.