-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Fix redis Connection::get() should be non blocking by default #31545
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/Transport/RedisExt/Connection.php
Outdated
Show resolved
Hide resolved
a64ef8e
to
454a738
Compare
ping @alexander-schranz also :) |
705b6f8
to
81136e7
Compare
src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
Outdated
Show resolved
Hide resolved
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.
xReadGroup should be non blocking aslong as we don't give a block time. Did I implement there something false?
And as written the xlen I think is the false way to get the correct count value as this does also include pending and received messages.
81136e7
to
f478351
Compare
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 discussed on slack this seems currently the only way to avoid a blocking request to omit the blocking parameter of xreadgroup function.
@chalasr thank you for fixing this 👍
f478351
to
229502a
Compare
Thank you @chalasr. |
…king by default (chalasr) This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] Fix redis Connection::get() should be non blocking by default | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | todo The `\Redis::xreadgroup()` method waits until a message arrives or the specified timeout is reached before returning, which means that `RedisExt\Connection::get()` is blocking. That's inconsistent with other transports which all returns immediately in case there is no message, for instance the AMQP transport uses `\Amqp::get()` instead of `\Amqp::consume()` for this reason. It also short-circuits the worker's stop logic: both the `--time-limit` option of the `messenger:consume` command and the `messenger:stop-workers` don't work with the redis transport. This returns early in case the message count is 0 and no blocking timeout has been configured. Commits ------- 229502a [Messenger] Make redis Connection::get() non blocking by default
The
\Redis::xreadgroup()
method waits until a message arrives or the specified timeout is reached before returning, which means thatRedisExt\Connection::get()
is blocking.That's inconsistent with other transports which all returns immediately in case there is no message, for instance the AMQP transport uses
\Amqp::get()
instead of\Amqp::consume()
for this reason.It also short-circuits the worker's stop logic: both the
--time-limit
option of themessenger:consume
command and themessenger:stop-workers
don't work with the redis transport.This returns early in case the message count is 0 and no blocking timeout has been configured.