0

A web application of Django on RHEL7, Gunicorn service got a MySQL exception #2014, saying "Commands out of sync; you can't run this command now".

This error happens only when get one attribute element ("/api/admin/eav/attribute/24/"), and all the other elements are OK, e.g. the logs below shows "/api/admin/eav/attribute/28/" is OK.

I have tried to restart the Gunicorn service, but the issue persists.

This web application has been working fine for years before, and we noticed this error only recently. The versions of Django, Python, and MySQL are pretty old now.

Many thanks in advance to any suggestion on fix.

I will also highly appreciate general debugging advice, on for example:

  • how to configure Django to print SQL query statement into log? (I suspect there is something wrong with the query, and want to manually try it out in MySQL Workbench. I'm still new to Django.)

  • Is there anything to check on MySQL side?

See details below, and let me know if you need more information. Thank you for your help.

Version:

  • Python: 2.7.5;

  • Django: django.VERSION (1, 8, 13, 'final', 0);

  • MySQL: '10.1.9-MariaDB'

Logs:

[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"
James
  • 1,373
  • 3
  • 13
  • 27

1 Answers1

0

It looks like there were some low-efficient SQL queries generated by Django, and created overwhelming work load to the system causing error on the database side.

For how to print SQL while running Django, you need to modify settings.py, and see more details on link below: log all sql queries

James
  • 1,373
  • 3
  • 13
  • 27