-
Notifications
You must be signed in to change notification settings - Fork 100
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
MySQL 8 with foreign keys: diff/push deadlock errors #105
Comments
That's surprising, I've never seen deadlocks in that specific spot. Is Skeema connecting to MySQL directly, or is it going through middleware / proxy (e.g. vtgate, proxysql, etc)? If so, I'd wonder if the deadlocks are actually coming from the middleware instead of mysql. One way to check would be to run In any case, for background on where this error is occurring:
If Skeema is already connecting to mysqld directly, a few follow-up questions:
|
It is connecting directly to MySQL. Ironically, the schema name we are using is
Percona 8.0.16
~20 tables
Yes, about 1-3 per table
Not in this schema
This is running inside Kubernetes in production, so I'm not keen to test that. :) |
Thanks, I'll look more into this. It's entirely possible that MySQL 8.0's new innodb data dictionary introduced new possible deadlocks when concurrently creating tables with FKs. I've previously seen that in 8.0 when concurrently dropping tables with FKs; Skeema already has logic to handle that. That condition was trivially easy to repro though (e.g. 2 tables with FKs + 2 concurrent threads), so perhaps the CREATE one is sneakier due to CREATE being lighter-weight than DROP. |
Also wanted to mention this potentially relates to #93, which I hope to focus on soon. |
I'm able to reproduce this now, and have confirmed it's specific to MySQL 8 with foreign keys. So far it does indeed appear to be related to concurrently creating tables with FKs in a workspace -- similar to the already-handled situation with concurrently dropping tables with FKs in a workspace, but less frequent unless the percentage of tables with FKs is high. I'm aiming to have a fix in master (plus integration test coverage) by tomorrow. Thank you again for reporting this! |
Now fixed in master branch, and will be included in the next patch release (probably in 1 to 2 weeks). This fix has been deployed to skeema.io CI today as well. Thanks again for reporting this bug! When cleaning up the related concurrency logic here I used your awesome package https://github.com/nozzle/throttler, so thank you for that too btw! It's much cleaner than the approach I had been using (fiddling with DB.SetMaxOpenConns) and makes the error tracking easier to manage as well :) |
Running
skeema diff
against an active master results in a deadlock error about 80% of the time for me. I'm not sure what I can do about it.Error executing DDL in workspace: Error 1213: Deadlock found when trying to get lock; try restarting transaction
The text was updated successfully, but these errors were encountered: