Kong/kong-python-pdk

Memory leak in server.py

Closed this issue · 5 comments

vtlkvl commented

We ran into a memory leak in Kong Plugin Server that can be reproduced as described in https://github.com/vtlkvl/kong-python-pluginserver-memory-leak. We figured out that for each plugin call the messaging queue is added to PluginServer.events in PluginServer.handle_event, but PluginServer._step and specifically removal of the queue is done just for the last plugin. So if you have 10 plugins, 10 queues will be added to PluginServer.events, but just 1 will be deleted and 9 will remain in the memory and never get GCed. As a result PluginServer.events will grow until OOM.

vtlkvl commented

@fffonion I've got a fix for the issue. Can I get write access to push a feature branch to make a PR?

@vtlkvl we usually don't grant access to community contributers, please creeate a fork and create PR from there : ) Feel free to ping me when it's ready.

Very good analysis on the memory issue btw 👍

vtlkvl commented

@fffonion I've made a PR. Once it is approved and merged, how long does it take to get a new version?

@vtlkvl I will release a new version once the PR is merged!

vtlkvl commented

It should be resolved in Kong PDK 0.35.