-
Notifications
You must be signed in to change notification settings - Fork 14
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
acquiring locks fails - Deadlock found when trying to get lock #28
Comments
Hey, thanks for the report! This doesn't seem like its referring to the Minion lock, but the underlying MySQL lock. But the backend doesn't explicitly lock any tables, so I'm going to need some information about how it occurs.
The only thing I can think of right now is to try to make sure that all the things that do work on different tables do that work in the same order, but that doesn't really make sense. Maybe I need to be more aggressive about commits and/or autocommit? |
I don't think it's referring to a literal lock command, I think it has to do with some kind of deadlock related to the minion_lock function: Minion-Backend-mysql/lib/Minion/Backend/mysql.pm Line 1078 in 8f50b67
I have jobs running that call guard to acquire a lock. These jobs are not calling for the same lock (the lock name is different). I will work on making a minimum reproduction case. I suspect that putting a sleep somewhere in the minion_lock function and then calling for two locks may help.
I'm actually just using Minion locks for distributed locking, but my jobs are jobs running on AWS Batch. However, I may have 10-15 jobs running at once, each trying to acquire a lock, but with different names (the same type of job only runs once, so no simultaneous jobs ask for the same lock).
I can use DBD::mysql. I am going to switch to this and see if the problem persists (I only see it happen a few times a day, so I may not really be sure if this helps until I make my repro case). One thing that I should note, is for several months before this I was using the exact same code, but with Minion::Backend::Pg and didn't see this problem (not sure how similar the code is between that and Minion::Backend::mysql, and obviously mysql and Pg are not the same!) :)
I will see if I can get my jobs to run using one of those modules. |
Can now confirm that I get the same error using DBD::mysql:
Still working on repro case |
Thanks! Also, which version / fork of mysqld are you running? I can add that to the travis tests to try to reproduce. |
It's 5.7, however, it's Amazon Aurora's version, which could make reproduction hard on Travis (and technically, could be causing the issue, although I would think not). The exact version is 5.7.mysql_aurora.2.07.2 |
We started hitting this same problem at work, so I was able to get the InnoDB locking information. It appears to be the Doing a proper |
[NOTE] This release tries to fix some reported deadlocks from job dequeuing by moving the dequeue process into a transaction with a `SELECT ... FOR UPDATE` query. Please make sure to test this release in your environment before moving it to production, and be prepared to roll back to v0.23. Please report any issues you have so they can get fixed! [Fixed] - Fix compatibility with Mojolicious 9.0: The tests would fail because the `delay` helper is no longer available. - Fix jobs being run before their parents. Thanks @tn-laslov for reporting this issue and providing the solution! [Github #34] - Fix slow job dequeue on very large jobs tables. Thanks @znestor for reporting this issue and providing the solution! [Github #33] - Trying to fix some reported deadlocks in job dequeueing. Thanks @srchulo for reporting and help debugging this issue, and Grant Street Group for additional debugging information. [Github #28] - Fix note values not accepting UTF-8 characters. Thanks @uralm1 for reporting this issue and providing a fix! [Github #32]
Awesome!! Thanks for fixing/figuring this out! |
I get this error frequently from my jobs when trying to acquire a lock:
DBD::MariaDB::st execute failed: Deadlock found when trying to get lock; try restarting transaction at /home/admin/local/lib/perl5/Minion/Backend/mysql.pm line 403.
I wonder if there's someway to prevent this or retry when this occurs?
https://dev.mysql.com/doc/refman/8.0/en/innodb-deadlocks.html
The text was updated successfully, but these errors were encountered: