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

Error: "commands out of sync. Did you run multiple statements at once?" #1673

Open
rks-lovelace opened this issue Jan 29, 2025 · 1 comment

Comments

@rks-lovelace
Copy link

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.

@methane
Copy link
Member

methane commented Jan 30, 2025

Please try master branch and tcpdump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants