-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Thread deadlocks on statement prepare under high load involving explicit locks #865
Comments
Here is issue tracker of driver. This is not a MySQL user forum or MySQL support. |
This is not a MariaDB issue. This is the driver thread deadlocking and not returning from statement prepare for a query. |
driver doesn't use any locks between threads(connections). |
Can you get goroutine dump when deadlock happens? |
This comment has been minimized.
This comment has been minimized.
After looking and running your code, it seems normal deadlock on the server. |
Issue description
Occasionally (race condition, I presume) preparing a SELECT / UPDATE / INSERT statement after issuing
LOCK TABLES foo WRITE, bar READ;
never returns. The transaction that is hanging has also been granted the locks effectively preventing other SQL connections to run their queries.We have not been able to produce this problem in small example code but we have observed it in automated unit testing (only when tests are run in parallel) and validated that the transaction that is holding the locks is idle and inside a Tx.Prepare() function call. Killing the query connection enables the other transactions to continue normally.
In trying to reproduce the bug in smaller code we observed that we are able to produce degraded performance (connections and transactions hanging on for a minute before resolving) but not a complete deadlock. We suspect that this is because of our application queries and transactions are more complex and may be running for longer.
Example code
With this code the jamming (which resolves eventually here) is present but full deadlock is not. This code will assume that a MariaDB database with name "fuzz" accessible for user "fuzz" without password is available. This will create 3 tables a, b and c and randomly read and write data in those. Eventually it will jam with 100% CPU utilization but no queries progressing and no disk activity.
Error log
From unit test run that jammed (first row lists the tx that's owned by the thread not progressing; 3 tables are locked for writes for that transaction)
After killing connection 10187 the error that was produced in go was
[mysql] 2018/10/04 15:20:12 packets.go:36: unexpected EOF
and the rest of the test threads executed normally.
Configuration
Driver version (or git SHA): 1.4.0
Go version: go version go1.11 linux/amd64
Server version: 10.1.36-MariaDB-1~xenial
Server OS: Ubuntu 16.04
The text was updated successfully, but these errors were encountered: