Internal server Error when submitting draft invoices

Hello Team

I am currently having issues submitting draft invoices on my instance. When i click on the submit button it says for about 5mins, freezes the enter server and then throws the error message ‘Internal Server Error’

checking the logs is traceback error as below

Traceback (most recent call last):
File “/home/ubuntu/xlevel/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 594, in save_invoice
si.insert(ignore_permissions=True)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/document.py”, line 217, in insert
self.set_new_name()
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/document.py”, line 378, in set_new_name
set_new_name(self)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 42, in set_new_name
set_name_from_naming_options(autoname, doc)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 71, in set_name_from_naming_options
set_name_by_naming_series(doc)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 87, in set_name_by_naming_series
doc.name = make_autoname(doc.naming_series+’.#####’, ‘’, doc)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 116, in make_autoname
n = parse_naming_series(parts, doctype, doc)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 131, in parse_naming_series
part = getseries(n, digits, doctype)
File “/home/ubuntu/xlevel/apps/frappe/frappe/model/naming.py”, line 159, in getseries
current = frappe.db.sql(“select current from tabSeries where name=%s for update”, (key,))
File “/home/ubuntu/xlevel/apps/frappe/frappe/database.py”, line 199, in sql
self._cursor.execute(query, values)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 516, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 727, in _read_query_result
result.read()
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1073, in read
self._read_result_packet(first_packet)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1143, in _read_result_packet
self._read_rowdata_packet()
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1177, in _read_rowdata_packet
packet = self.connection._read_packet()
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 683, in _read_packet
packet.check_error()
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/ubuntu/xlevel/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
InternalError: (1205, u’Lock wait timeout exceeded; try restarting transaction’)

While troubleshooting, i logged on to my database and ran show processlist; which returned image as below

When i kill the running ID with 1316 my server starts responding again…

will appreciate tips to resolve this issue

Perhaps you have an error or some corruption in your naming series table?
Those values are stored in tabSeries.

  • Do you have any custom apps that might have locked this table?
  • Have you run an update/migrate to makes sure the DB schemas are matched?

i have few custom apps but not related to naming series…everything has been running before now, issue just started few weeks back…

i cant run update or migrate on a live server but i did take a backup to a Lab server and i did update and migrate and i still have same issue