在从作为 Flask 下的 uWSGI 进程运行的 Pandas 中的 HDF5 存储中进行选择时,我遇到了分段错误。它可以很好地执行几个块,但一段时间后会遇到问题。*是我自己的日志记录,基本上我们进入第 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 development :5000 端口运行该过程,它从头到尾运行良好。这也不是内存不足的问题(每个 uWSGI 都分配了足够的内存,并且在运行期间不会用完)。我知道我应该在不久的将来将这个过程从 uWSGI 解耦到 Celery 或其他东西;)但如果它现在可以工作那就太好了!我也不认为它是 uWSGI harakiri(无论如何都会给出不同的日志)
设置:
- 烧瓶:0.10.0
- uWSGI:1.9.18
- 熊猫:0.12.0
- 蟒蛇:2.7.3
- Ubuntu 12.04LTS 服务器,64 位
- 32gb 内存,4 个 8gb uwsgi worker
uwsgi 配置:
<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:对于通过 google 找到此内容的任何人,最后我创建了一个 pre-fork 缓存解决方案,这意味着我可以拥有许多工作人员,但仍然非常高效。这确实意味着您必须在数据更改后重新启动 uwsgi 进程