Kong / Kong/kong-python-pdk

Memory leak with kong.response.exit

Open
#137 0 comments 0 reactions 1 assignee View on GitHub

@nowNick is already working on this.

Since Jan 29, 2024.

bug
Dominant language
Python
Stars
48
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Hi Kong team,

We ran into another memory leak in the plugin server and were able to boil it down to the following pattern:

try:
    return kong.response.exit(some_response_code)
finally:
    kong.ctx.shared.set("memory", "leak")

I didn't have much time to debug the plugin server code myself, but the thing is that kong.response.exit does not terminate the execution of Python code and it seems that kong.ctx.shared.set (or virtually any other PDK API call) is going to create a new event queue after it was deleted by kong.response.exit. The new queue is never deleted and it's causing the memory leak.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.