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

implement a TTL for RedisChannelLayer.receive_buffer (to avoid a memory leak) #213

Closed
wants to merge 1 commit into from

Conversation

ryanpetrello
Copy link
Contributor

@ryanpetrello ryanpetrello commented Jul 27, 2020

@@ -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()
Copy link
Contributor Author

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.

@ryanpetrello ryanpetrello force-pushed the recv_buffer_leak branch 7 times, most recently from 2e8097f to dd894ad Compare July 27, 2020 21:09
@ryanpetrello
Copy link
Contributor Author

Using https://github.com/ryanpetrello/channels-redis-leak as a reproducer, I've applied this patch.

Here's a bunch of references to messages:

image

...here's what happens if I wait 60+ seconds and disconnect/reconnect w/ a new websocket client:

image

@ryanpetrello ryanpetrello changed the title implement a TTL for RedisChannelLayer.receive_buffer implement a TTL for RedisChannelLayer.receive_buffer (to avoid a memory leak) Jul 27, 2020
@ryanpetrello
Copy link
Contributor Author

ryanpetrello commented Aug 11, 2020

On further testing, this seems like it also slowly leaks 😞

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

Successfully merging this pull request may close these issues.

1 participant