-
Notifications
You must be signed in to change notification settings - Fork 198
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
implement a TTL for RedisChannelLayer.receive_buffer (to avoid a memory leak) #213
Conversation
@@ -616,6 +651,7 @@ async def group_discard(self, group, channel): | |||
key = self._group_key(group) | |||
async with self.connection(self.consistent_hash(group)) as connection: | |||
await connection.zrem(key, channel) | |||
self.receive_buffer.expire() |
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.
Maybe we can't rely on this only happening on group_discard
(since some may not be using the group extension?).
Doing this sort of thing once per receive()
call seems too expensive, though.
2e8097f
to
dd894ad
Compare
Using https://github.com/ryanpetrello/channels-redis-leak as a reproducer, I've applied this patch. Here's a bunch of references to messages: ...here's what happens if I wait 60+ seconds and disconnect/reconnect w/ a new websocket client: |
dd894ad
to
3f66c3c
Compare
On further testing, this seems like it also slowly leaks 😞 |
see: #212
cc @carltongibson @agronick