Timeout and Error while submitting Sales Invoice

I am getting a 504 timeout error while submitting a large sales invoice with 150 items.
The screen is grey for a while and then I finally get a timeout error on the console.

On looking at the logs this is what I found:
Traceback (innermost last):
File “/home/erpnext/frappe-bench/apps/frappe/frappe/app.py”, line 49, in application
response = frappe.handler.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 531, in call
return fn(*args, **newargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/widgets/form/save.py”, line 18, in savedocs
doc.save()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py”, line 175, in save
self.insert()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py”, line 139, in insert
self.set_new_name()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py”, line 221, in set_new_name
set_new_name(self)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/naming.py”, line 38, in set_new_name
doc.name = make_autoname(doc.naming_series+‘.#####’)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/naming.py”, line 100, in make_autoname
en = getseries(n, digits, doctype)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/naming.py”, line 116, in getseries
current = frappe.db.sql(“select current from tabSeries where name=%s for update”, (key,))
File “/home/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 110, in sql
self._cursor.execute(query, values)
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1205, ‘Lock wait timeout exceeded; try restarting transaction’)

Is this related to mysql or nginx and gunicorn, I looked at a few posts related to timeout and made some changes to the my.cnf and nginx configuration file but the error persists.

1 Like

This might happen if you make a back-dated entry, as the system tries to repost all future transactions.

The entries are current dated. Can’t understand why the transaction is getting locked by another process.

wherever I face this issue following command works for me. :+1:

bench update --patch

#solution #solved

1 Like

i have sinv from past two month i can’t submit it … i try your solution didn’t work with me

same problem here