Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Messenger] return empty envelopes when RetryableException occurs#32979
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Messenger] return empty envelopes when RetryableException occurs#32979
Uh oh!
There was an error while loading.Please reload this page.
Conversation
b94e988 toa5693f5Compare8189b65 to864b51dComparesrc/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Tobion left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
We should add a safety counter tocatch (RetryableException $exception) so when it's happens like 3 times in a row, we rethrow. Otherwise a permanent deadlock or misconfiguration of timeouts might be invisible as you would always just hide the exception.
surikman commentedAug 7, 2019
@Tobion Thanks. I implemented safety counter as you described. |
ca322e5 to20cddc3Comparesrc/Symfony/Component/Messenger/Transport/Doctrine/Connection.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
877c401 to8e69051Comparesrc/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
8e69051 toc64f5aeCompare| thrownewTransportException($exception->getMessage(),0,$exception); | ||
| } | ||
| return []; |
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.
Wouldn't it be better to retry "internally" (i.e.return $this->get()) instead of returning this empty array? Otherwise, in the event of using multiple transports, the worker might start consuming lower priority messages, which would make no sense. Similar withwhatever might decorate this receiver... it would "see" an empty array while actually, it was an error.
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.
Does not seem better to me. This way we can use the delay that is added after the get which is what we want with a deadlock/timeout problem.
nicolas-grekas left a comment
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.
@sroze we need your approval here
Uh oh!
There was an error while loading.Please reload this page.
Tobion commentedSep 27, 2019
Thank you@surikman. |
c64f5ae to9add32aCompare… occurs (surikman)This PR was squashed before being merged into the 4.3 branch (closes#32979).Discussion----------[Messenger] return empty envelopes when RetryableException occurs| Q | A| ------------- | ---| Branch? | 3.4 or 4.3 for bug fixes <!-- see below -->| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| License | MIT| ~~Doc PR~~ | ~~symfony/symfony-docs#12109~~<!--Replace this notice by a short README for your feature/bugfix. This will help peopleunderstand your PR and can be used as a start for the documentation.Additionally (seehttps://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch.-->Problem occurs when you are using more than 1 worker with Doctrine Transport.`Symfony\Component\Messenger\Transport\Doctrine\Connection::get` does a query `SELECT ... FOR UPDATE` and this locking query could lock table and workers stops. But using locks can result in dead locks or lock timeouts. Doctrine renders these SQL errors as RetryableExceptions. These exceptions are often normal if you are in a high concurrency environment. They can happen very often and your application should handle them properly.Commits-------9add32a [Messenger] return empty envelopes when RetryableException occurs
Uh oh!
There was an error while loading.Please reload this page.
Doc PRsymfony/symfony-docs#12109Problem occurs when you are using more than 1 worker with Doctrine Transport.
Symfony\Component\Messenger\Transport\Doctrine\Connection::getdoes a querySELECT ... FOR UPDATEand this locking query could lock table and workers stops. But using locks can result in dead locks or lock timeouts. Doctrine renders these SQL errors as RetryableExceptions. These exceptions are often normal if you are in a high concurrency environment. They can happen very often and your application should handle them properly.