Memory leak issue in rest_tornado EventListener #24846
Labels
Bug
broken, incorrect, or confusing behavior
P4
Priority 4
Salt-API
severity-medium
3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone
Issue brief
In salt/rest_tornado/saltnado.py -> EventListener, there're three maps for tracking the futures when doing synchronous call, request_map, tag_map and newly introduced timeout_map. While tag_map gets cleaned upon future completion or request response return, the other two never get cleaned and causing memory leak (depends on the payload content). Here's the memory profiling data based on 10k *http://localhost:8000/minions/**\ calls:
1st patch
Here's the first patch I applied to clean those 2 maps up upon a request completion:
And here's the profiling result on ubuntu-12.04:
Yet, there're still some left over requests in request_map when testing on my macbook. It might be introduced due to kqueue on BSD/Mac behaves different from epoll on Linux in racing condition, but I cannot figure that out. Also the memory profiling does not work smoothly on mac and crashed several times in the middle due to bad file descriptor.
2nd patch
I end up with the second patch to move the request_map into request itself such that the whole request and its resources can be GCed after completion.
And here's the profiling on ubuntu, a little bit longer, probably due to longer reference path walking for GC.
For fixing
I would prefer the 2nd patch which isolates the request map more reasonable to the request object itself. Haven't been going through the pull request before. If it's a preferred contribution style, I will follow the guide.
The text was updated successfully, but these errors were encountered: