RHEL7上的Django web应用程序Gunicorn服务获得了一个MySQL异常#2014,上面写着“命令不同步,您现在不能运行这个命令”。
只有当获取一个属性元素(“/api/admin/eav//24/”)并且所有其他元素都是OK时,才会发生此错误,例如下面的日志显示“/api/admin/eav//28/”是OK的。
我试图重新启动Gunicorn的服务,但问题依然存在。
这个web应用程序在过去几年一直运行良好,我们直到最近才注意到这个错误。Django、Python和MySQL的版本现在已经相当陈旧了。
事先对任何关于固定的建议表示感谢。
我还将非常感谢一般调试建议,例如:
请参阅下面的详细信息,如果您需要更多的信息,请告诉我。谢谢你的帮助。
版本:
2.7.5;
日志:
[2020-03-20 18:17:37 +0000] [29744] [DEBUG] GET /api/admin/eav/attribute/
- - [20/Mar/2020:18:17:38 -0600] "GET /api/admin/eav/attribute/ HTTP/1.0" 200 56843 "https://domain.under.test/api/admin/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
[2020-03-20 18:17:57 +0000] [29744] [DEBUG] GET /api/admin/eav/attribute/28/
- - [20/Mar/2020:18:17:59 -0600] "GET /api/admin/eav/attribute/28/ HTTP/1.0" 200 280775 "https://domain.under.test/api/admin/eav/attribute/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
[2020-03-20 18:18:00 +0000] [29744] [DEBUG] GET /api/admin/jsi18n/
- - [20/Mar/2020:18:18:00 -0600] "GET /api/admin/jsi18n/ HTTP/1.0" 200 2372 "https://domain.under.test/api/admin/eav/attribute/28/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
[2020-03-20 18:18:14 +0000] [29741] [DEBUG] GET /api/admin/eav/attribute/
- - [20/Mar/2020:18:18:14 -0600] "GET /api/admin/eav/attribute/ HTTP/1.0" 200 56843 "https://domain.under.test/api/admin/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
[2020-03-20 18:18:23 +0000] [29738] [DEBUG] GET /api/admin/eav/attribute/24/
[2020-03-20 18:18:54 +0000] [29705] [CRITICAL] WORKER TIMEOUT (pid:29738)
[2020-03-20 18:18:54 +0000] [29738] [INFO] Worker exiting (pid: 29738)
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x7f82a329ec50>> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <generator object cursor_iter at 0x7f82a328e500> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x7f82a32a7cd0>> ignored
[2020-03-20 18:18:54 +0000] [29915] [INFO] Booting worker with pid: 29915
/webapp/EBACKEND/eav/models.py:42: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
[2020-03-20 18:21:40 +0000] [29915] [DEBUG] GET /api/admin/eav/attribute/
- - [20/Mar/2020:18:21:40 -0600] "GET /api/admin/eav/attribute/ HTTP/1.0" 200 56843 "https://domain.under.test/api/admin/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
发布于 2020-03-24 20:51:12
看起来,Django生成了一些低效率的SQL查询,给系统造成了巨大的工作量,导致数据库端出现错误。
有关如何在运行Django时打印SQL,需要修改settings.py,并查看以下链接的详细信息:log all sql queries
https://stackoverflow.com/questions/60783653
复制相似问题