-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Improve deadlock handling on ack()
and reject()
#54105
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
Conversation
src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
Outdated
Show resolved
Hide resolved
ack()
and reject()
ack()
and reject()
ack()
and reject()
ack()
and reject()
ack()
and reject()
After discussing this with Nicolas, I am going to remove the |
src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineReceiver.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineReceiver.php
Outdated
Show resolved
Hide resolved
@@ -21,6 +21,7 @@ | |||
use Doctrine\DBAL\Platforms\MySQLPlatform; | |||
use Doctrine\DBAL\Platforms\OraclePlatform; | |||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | |||
use Doctrine\DBAL\Query\ForUpdate\ConflictResolutionMode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as i can see, this was added in dbal 3.8, but we support versions prior to that
https://github.com/symfony/doctrine-messenger/blob/6.4/composer.json#L20C10-L20C23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may have to manually construct the sql, as is done below with the method_exists(QueryBuilder::class, 'forUpdate')
checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will see. The sql for each platform is not as simple as just appending SKIP LOCKED. And in fact now that you point it out, I suspect this code might be broken for other platforms when you are using older versions of doctrine/dbal where the forUpdate() abstraction does not exist yet.
src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineReceiverTest.php
Show resolved
Hide resolved
Thank you @jwage. |
We started getting this deadlock recently. It has happened only twice so far under high load.
Here are the queries for each process:
Open for discussion if this is the right way to handle this or not.
TODO:
skip_locked
even be an option or should we always use skip locked?SKIP LOCKED
to theFOR UPDATE
? It will reduce contention further. I was looking at how SolidQueue in Ruby On Rails handles this and it appears they useSKIP LOCKED FOR UPDATE
https://github.com/basecamp/solid_queue/blob/fe57349a126efc381fe0adf4c1ec444bd8a4f53f/app/models/solid_queue/record.rb#L11