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
[Messenger] PostgreSQL: new messages are not picked up for 60 seconds #45056
Comments
'use_notify' => true,
'get_notify_timeout' => 0
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php Line 85 in 6cdfd71
edited: |
I had the issue too, that the consumer picked up new messages only after 60 seconds. I also thought it might be due to the The 60 seconds delay is the default polling rate, when NOTIFY/LISTEN feature is not used. In my case the problem is actually sitting in this check, maybe it's the same in your case: symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php Line 51 in acf1f71
I have installed the |
yes we have the trigger, and our problem is not sentry. as per the OP, this line is the problem: symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php Line 90 in 6cdfd71
once the queue is emptied, new messages won't be checked for 60 seconds. |
That's not what that line does, because you're ignoring the first condition. The check is only delayed, if there is no notification or the notification is not related to the checked queue. Check the whole if and notice the symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php Lines 86 to 91 in 6cdfd71
If a notification for the queue is received, then the first part will fail and the delay-condition won't be checked. So your issue must be caused either by the notification not being triggered, or the listen not being notified. Edit: The method itself by default is actually called every second, which also if configurable with the |
@Sajito thanks for your reply. I've investigated again, and what I am finding is that the listener is being "lost". the listener is setup here: symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php Line 72 in 6cdfd71
just above the $listeners = $this->driverConnection->fetchAssociative('select * from pg_listening_channels();'); which correctly shows the listener the first time around. this appears to be why now, need to figure out what's happening to the listener. |
and.. it's the so the |
Thanks for investigating @bendavies! Do you want to work on a patch? |
@dunglas yes, but...choices:
any preferences? |
I have the same issue. What is the harm of querying
In that way it would be possible to stop keeping track of "are we listening or not" and remove the |
Nice find. That sounds good |
I'll work on this next week |
@bendavies Hi. Any updates on this? |
#47209 is the pull request implementing #45056 (comment) |
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- Always attempt to listen for notifications | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #45056 | License | MIT as discussed in #45056 (comment), when a middleware closes the connection, the messenger consumer will not receive notifications when a new record is inserted. Since is safe to call `LISTEN` multiple times, we can avoid having to keep tack if we did call or not the listen command, we call it always so we are always sure to get notifications with new messages are added. Commits ------- 72ac5bf Always attempt to listen for notifications
Symfony version(s) affected
5.3 onwards
Description
Hi,
There appears to be a bug in PostgreSqlConnection meaning that newly available messages are not picked immediately.
This is due to this line:
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php
Line 90 in 6cdfd71
I really don't understand what that line is doing apart from being something to do with delayed message, but apart from that don't understand it.
How to reproduce
bin/console messenger:consume async -vvv
Simply: after the queue is emptied, new messages will not be picked up for 60 seconds because of
check_delayed_interval' => 60000
Possible Solution
Unsure, no idea what
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php
Line 90 in 6cdfd71
Additional Context
Found a related discussion #36990
The text was updated successfully, but these errors were encountered: