You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiproc files not cleaned up if worker gets segfault/oom/... #115
In multiproc mode, if one of the gunicorn workers gets killed because of a segfault or out-of-memory situation, it doesn't get a chance to clean up its .db files. These files are thus left in the multiproc folder, distorting the metrics.
Maybe this can be solved by moving the cleanup hook into the gunicorn "master" process. My suggestion is to solve this in the Python client instead, by deleting all .db files with dead PIDs before aggregating the metrics.
This is by design. It's incorrect to delete the files while the process is still running, and it's expected that the user will clean them up during restarts.
In a segfault or OOM situation the process isn't running anymore. The gunicorn cleanup example in the documentation is incomplete; it doesn't cover the "Python crashes" situation.
So I'm not sure about for how long PIDs aren't reused, but I doubt it's quicker than the usual Prometheus scrape interval. In addition we could check if the PIDs are child processes of the aggregating parent process. What are the chances that a new worker process with the same PID is spawned within the scrape interval?
@jonashaag@brian-brazil Sorry for the ping if you were already aware, but I just wanted to make sure you knew that gunicorn 19.7.0 was released on March 1 with the child_exit() callback added, so this should be possible to implement now: http://docs.gunicorn.org/en/latest/news.html#id1
Activity
Fix prometheus#115
brian-brazil commentedon Nov 11, 2016
This is by design. It's incorrect to delete the files while the process is still running, and it's expected that the user will clean them up during restarts.
jonashaag commentedon Nov 11, 2016
In a segfault or OOM situation the process isn't running anymore. The gunicorn cleanup example in the documentation is incomplete; it doesn't cover the "Python crashes" situation.
brian-brazil commentedon Nov 11, 2016
I had thought worker_exit was handled in the master, presumably by doing a
wait. Is that not the case?jonashaag commentedon Nov 11, 2016
No, see https://github.com/benoitc/gunicorn/blob/2b839ca14437c61780d6eaaa8b24ad31e021f2c6/gunicorn/arbiter.py#L576 (this is in the fork child branch)
brian-brazil commentedon Nov 11, 2016
Hmm, can we get a feature request in to be able to hook into reap_workers?
jonashaag commentedon Nov 11, 2016
This would only work for gunicorn though. What do you think about my suggestion, which is a much more general solution to the problem?
brian-brazil commentedon Nov 11, 2016
You're presuming that pids are never reused, and deleting too many tiles. A solution based on
waitis the proper solution.jonashaag commentedon Nov 11, 2016
So I'm not sure about for how long PIDs aren't reused, but I doubt it's quicker than the usual Prometheus scrape interval. In addition we could check if the PIDs are child processes of the aggregating parent process. What are the chances that a new worker process with the same PID is spawned within the scrape interval?
Maybe we should incorporate both solutions.
brian-brazil commentedon Nov 11, 2016
That depends on how many processes are being spawned, and how the pid allocation strategy is.
We don't actually know that the values are pids. They could be worker IDs (indeed it's better if they are, less label churn).
jonashaag commentedon Nov 12, 2016
I see. To me this is a prime example of leaky abstraction that has to be improved.
Is your final suggestion to hook into
reap_workers, i.e. make the forking process's responsibility to deal with all sorts of worker exits?brian-brazil commentedon Nov 12, 2016
Yes. The only sane way to handle this it to make it the parent process's responsibility.
Deimos commentedon Mar 6, 2017
@jonashaag @brian-brazil Sorry for the ping if you were already aware, but I just wanted to make sure you knew that gunicorn 19.7.0 was released on March 1 with the
child_exit()callback added, so this should be possible to implement now: http://docs.gunicorn.org/en/latest/news.html#id1brian-brazil commentedon Mar 17, 2017
Gunicorn has the required feature now.