Skip to content
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

[RedisMessengerBridge] Add a delete_after_ack option #36464

Merged
merged 1 commit into from Apr 17, 2020

Conversation

Seldaek
Copy link
Member

@Seldaek Seldaek commented Apr 16, 2020

This allows Messenger to clean up processed messages from memory, avoiding a mem "leak" in redis

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets #33715
License MIT
Doc PR symfony/symfony-docs#... TODO - will pile it on to symfony/symfony-docs#11869 as it kinda binds together and a bigger refactor of the docs here is much needed to avoid all these gotchas

Right now by default a redis transport for messenger will leak memory as all messages stay in redis forever. You can configure stream_max_entries to automatically trim to a max of X entries, but that means if you have big peaks in messages you might start losing messages which have not been processed.

This PR provides an alternative to that, by deleting message as they are processed. This is ideal as it avoids having to find the right number for stream_max_entries (do you want to risk losing data or use more memory than needed on average?). The only catch is that if you have multiple groups consuming the same stream, the first one processing a message will delete it, so other groups will not see it. For that reason setup() attempts to detect this and fails hard if it is misconfigured to prevent data loss.

@chalasr
Copy link
Member

chalasr commented Apr 16, 2020

Should be enough to close #33715.

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to tests are broken.

@Seldaek
Copy link
Member Author

Seldaek commented Apr 17, 2020

Fixed tests now, seems the failing ones are unrelated.

@fabpot
Copy link
Member

fabpot commented Apr 17, 2020

Thank you @Seldaek.

@plfort
Copy link
Contributor

plfort commented Aug 31, 2020

Does this feature can be backported on 4.4 ?

@stloyd
Copy link
Contributor

stloyd commented Aug 31, 2020

@plfort New feature are never backported into already released versions, backported are only bugfixes.

@Seldaek Seldaek deleted the redis-delete-after-ack branch September 1, 2020 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants