-
Notifications
You must be signed in to change notification settings - Fork 11k
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
ShouldBeUniqueUntilProcessing job with afterCommit get persist lock on failed database transactions and unable to dispatch again #47761
Comments
I created a Pull Request. Unfortunately, lot of tests failed, because the logic is different now. This is a very tricky part, I tried to follow the main concept of queue classes structure, but unfortunately only Queue class has the things I need, so I moved some logic there from PendingDispatch class. We have critical bugs in our project because of that. And we can't bind anything via container, because all objects are created with |
Let's see how your PR goes first 👍 |
As I sad, my PR failed with auto-tests, and I can't find any instruction how to configure them correctly to be the same as it does automatically. I even posted a question in Discussions (#47764), but no response on this. |
@driesvints , in case you missed the PR, it was already linked to this issue: #47765. |
I'm going to close this now because no new PR has been made. Feel free to try again if you want 👍 |
Laravel Version
10.6.2, 10.15.0
PHP Version
8.2.6
Database Driver & Version
MySQL 8.0.30; Redis 7
Description
If queue afterCommit flag is true and database transaction failed (will be rolled back), then all jobs dispatched with ShouldBeUniqueUntilProcessing interface will get a persistent lock, and you can't dispatch them again at all (because there are no any instruments to clear the locks from redis).
This happens because on transaction rollback the Job is not dispatched, but lock is already set and is not released.
So afterwards - you can't dispatch this job again, because the lock is exists.
The only possible workaround right now is to set some $uniqueFor value, so the lock will expire in some time. But this is a bit wrong behavior, when I really need ShouldBeUniqueUntilProcessing without expiration.
Similar issues were reported already without any fix:
Steps To Reproduce
redis
php artisan queue:work
php artisan app:dispatch-job-within-failed-transaction --commit
php artisan app:dispatch-job-within-failed-transaction --rollback
> no job has been executed, this is okayphp artisan app:dispatch-job-within-failed-transaction --commit
The text was updated successfully, but these errors were encountered: