Gunicorn服务RHEL7上Django的一个web应用程序出现MySQL异常#2014,表示“命令不同步;您现在无法运行此命令”
仅当获取一个属性元素(“/api/admin/eav/attribute/24/”)且所有其他元素都正常时,才会发生此错误,例如,下面的日志显示“/api/admin/eav/attribute/28/”正常
我已尝试重新启动Gunicorn服务,但问题仍然存在
这个web应用程序多年前一直运行良好,直到最近我们才注意到这个错误。Django、Python和MySQL的版本现在已经很旧了
非常感谢您对修复的任何建议
我还将非常感谢一般调试建议,例如:
如何配置Django将SQL查询语句打印到日志中?(我怀疑查询有问题,想在MySQL Workbench中手动试用。我对Django还是新手。)
MySQL方面有什么需要检查的吗
请参阅下面的详细信息,如果您需要更多信息,请告诉我。谢谢你的帮助
版本:
Python:2.7.5
Django:Django.VERSION(1,8,13,'final',0)
MySQL:“10.1.9-MariaDB”
日志:
[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"
看起来Django生成了一些低效的SQL查询,给系统造成了巨大的工作负载,导致数据库端出现错误
有关如何在运行Django时打印SQL,您需要修改settings.py,并查看下面链接的更多详细信息: log all sql queries
相关问题 更多 >
编程相关推荐