在Pandas中的HDF5商店中选择作为Flask下的uWSGI进程运行时,我遇到了分段错误。它可以很好地处理几个块,但过了一段时间后会遇到问题。 * 是我自己的日志记录,基本上我们进入第16轮进程,将一大块14531行与基表进行比较,然后保存结果。从HDF5检索数据时出错:
*** Processing Chunk: 16
*** Saving # Rows: 14531
*** Measure list: [-3, -2]
*** Retrieve Data
*** No Cache In Memory!
!!! uWSGI process 14786 got Segmentation Fault !!!
*** backtrace of 14786 ***
uwsgi(uwsgi_backtrace+0x29) [0x45f029]
uwsgi(uwsgi_segfault+0x21) [0x45f1b1]
/lib/x86_64-linux-gnu/libc.so.6(+0x364a0) [0x7fb50c92c4a0]
/srv/www/li/venv/local/lib/python2.7/site-packages/pandas/hashtable.so(+0x10ae9) [0x7fb506cc9ae9]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/srv/www/li/venv/local/lib/python2.7/site-packages/pandas/index.so(+0xda6c) [0x7fb505f90a6c]
/srv/www/li/venv/local/lib/python2.7/site-packages/pandas/index.so(+0xac77) [0x7fb505f8dc77]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x3bff) [0x7fb50cf88e2f]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(+0x5c86d) [0x7fb50cf4a86d]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(+0x12539f) [0x7fb50d01339f]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(+0xc7676) [0x7fb50cfb5676]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x3bff) [0x7fb50cf88e2f]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(+0x5c970) [0x7fb50cf4a970]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2b2a) [0x7fb50cf87d5a]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x614b) [0x7fb50cf8b37b]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5420) [0x7fb50cf8a650]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x614b) [0x7fb50cf8b37b]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(+0x5c970) [0x7fb50cf4a970]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2b2a) [0x7fb50cf87d5a]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(+0x5c970) [0x7fb50cf4a970]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2b2a) [0x7fb50cf87d5a]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x614b) [0x7fb50cf8b37b]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x614b) [0x7fb50cf8b37b]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x614b) [0x7fb50cf8b37b]
/usr/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x855) [0x7fb50cf4a6b5]
/usr/lib/libpython2.7.so.1.0(+0x5c86d) [0x7fb50cf4a86d]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(+0x12539f) [0x7fb50d01339f]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(+0x13153c) [0x7fb50d01f53c]
/usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53) [0x7fb50d02f053]
/usr/lib/libpython2.7.so.1.0(PyEval_CallObjectWithKeywords+0x47) [0x7fb50d02f9a7]
uwsgi(python_call+0x1f) [0x470daf]
uwsgi(uwsgi_request_wsgi+0x11e) [0x472ffe]
*** end of backtrace ***
DAMN ! worker 1 (pid: 14786) died, killed by signal 11 :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 15975)
mapping worker 1 to CPUs: 0
有谁知道造成这种情况的原因是什么?如果我使用Flask开发:5000端口运行该过程,它从头到尾运行良好。它也不是缺少内存问题(每个uWSGI都分配了足够的内存,并且在运行期间不会耗尽它)。 我知道我应该把这个过程从uWSGI分离到Celery或者在不久的将来;但是如果它现在可以工作的话会很好!我不认为这是uWSGI harakiri(无论如何都会提供不同的日志)
设置:
uwsgi config:
<uwsgi>
<uid>www-data</uid>
<gid>www-data</gid>
<socket>/tmp/li.socket</socket>
<chmod-socket>666</chmod-socket>
<chdir>/srv/www/li</chdir>
<pythonpath>/srv/www/li</pythonpath>
<virtualenv>/srv/www/li/venv</virtualenv>
<module>li</module>
<wsgi-file>/srv/www/li/li.py</wsgi-file>
<callable>app</callable>
<master/>
<processes>4</processes>
<pidfile>/tmp/li.pid</pidfile>
<harakiri>12000</harakiri>
<reload-mercy>8</reload-mercy>
<cpu-affinity>1</cpu-affinity>
<stats>/tmp/stats.socket</stats>
<max-requests>2000</max-requests>
<limit-as>8192</limit-as>
<reload-on-as>8192</reload-on-as>
<reload-on-rss>8192</reload-on-rss>
<no-orphans/>
<vacuum/>
</uwsgi>
任何帮助都将受到高度赞赏!
编辑:在尝试一系列配置后,3名10gb的工作人员不会遇到分段错误。它仍然非常奇怪,因为工人最多不使用超过4.5gb,通常使用1.8gb ......
编辑2:对于任何通过谷歌发现这一点的人,最后我创建了一个预分叉缓存解决方案,这意味着我可以拥有许多工作者,但仍然非常有效。它确实意味着你必须在数据改变后重新启动一个uwsgi进程