Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger][Redis] Transport can claim only single message per claim_interval #49023

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

Open
AdamKatzDev opened this issue Jan 18, 2023 · 7 comments

Comments

@AdamKatzDev
Copy link
Contributor

Symfony version(s) affected

5.4, 6.3

Description

https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

After a message is claimed nextClaim field is reseted:

if (\count($claimableIds) > 0) {
try {
$this->getRedis()->xclaim(
$this->stream,
$this->group,
$this->consumer,
$this->redeliverTimeout,
$claimableIds,
['JUSTID']
);
$this->couldHavePendingMessages = true;
} catch (\RedisException $e) {
throw new TransportException($e->getMessage(), 0, $e);
}
}
$this->nextClaim = microtime(true) + $this->claimInterval;
}

which does not allow to claim next messages:
if (!$this->couldHavePendingMessages && $this->nextClaim <= microtime(true)) {
$this->claimOldPendingMessages();
}

This logic might be intended and works in many cases but it doesn't work well for batch workers with large batch size or large claim_interval setting. It can potentially cause messages to pile up in worst cases or to be processed far too late.

How to reproduce

Possible to reproduce this by SIGKILL'ing a batch worker with messages stored. I hope that my explanation is good enough and a reproducer is not needed.

Possible Solution

Should be possible to fix this by moving nextClaim update to a different place. The field should not be updated if there is a pending message with the same consumer (already does) or a message from another consumer was claimed (this bug).

Additional Context

No response

@xabbuh
Copy link
Member

xabbuh commented Jan 18, 2023

Are you up to open a PR with the solution that you have in mind @AdamKatzDev?

@AdamKatzDev
Copy link
Contributor Author

@xabbuh, done.

@AdamKatzDev
Copy link
Contributor Author

Nope, not done, need to consider more things.

@AdamKatzDev
Copy link
Contributor Author

The PR should be done now.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Hello? This issue is about to be closed if nobody replies.

@AdamKatzDev
Copy link
Contributor Author

Keep it open, dear bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants