Sales Invoice Timeout Issues

I have set up erp next on google cloud and work like a charm.

After one month now I can not submit sales invoices getting time out error

I found below error snapshot

Error Report
Python 2.7.13: /home/frappe/frappe-bench/env/bin/python (prefix: /home/frappe/frappe-bench/env)

Timestamp:
2019-09-22 10:31:50.402291
Relapsed
28
Exception
args (‘get_bin_details_and_serial_nos() takes at least 3 arguments (4 given)’,)
message ‘get_bin_details_and_serial_nos() takes at least 3 arguments (4 given)’
Locals
args ()
fn
kwargs {‘cmd’: u’erpnext.stock.get_item_details.get_bin_details_and_serial_nos’, ‘item_code’: u’3/4’, ‘serial_no’: u’’, ‘stock_qty’: u’0’, ‘warehouse’: u’Finished Goods - DM’}
newargs {‘item_code’: u’3/4’, ‘serial_no’: u’’, ‘stock_qty’: u’0’, ‘warehouse’: u’Finished Goods - DM’}
Traceback
/home/frappe/frappe-bench/apps/frappe/frappe/app.py: 61

59
60 if frappe.local.form_dict.cmd:
61 response = frappe.handler.handle()
62
63 elif frappe.request.path.startswith("/api/"):
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 21

19
20 if cmd!=‘login’:
21 data = execute_cmd(cmd)
22
23 # data can be an empty string or list which are valid responses
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 56

54 is_whitelisted(method)
55
56 return frappe.call(method, **frappe.form_dict)
57
58
/home/frappe/frappe-bench/apps/frappe/frappe/init.py: 1036

1034 newargs = get_newargs(fn, kwargs)
1035
1036 return fn(*args, **newargs)
1037
1038 def get_newargs(fn, kwargs):

Any one have idea what happen suddenly.

I will much appreciate your support on this.

I am stuck

I have got the back up and restored to another instance and problem has not solved.

I have bunch of error snapshots.

Just to add more information,

I have got a back up and restored in my local VM and got me the same result.

yeah, it’s true that, erpnext guys keep destroying our dream to get reliable system.

I follow up this platform since version 2 or alike, despite annoying errors at installation which vary from version to another, the most terrible is update/upgrade sometimes spoil everything and no way to start from scratch with tedious works of data export/import to get updated system.

The question is, why not packaging deb file with repo for continual upgrade?
my opinion is, it requires very careful testing before pushing which erpnext guys are sacrificing for the sake of surprising us with new annoying version doesn’t work or at least to make it much difficult for us!

see?!
I didn’t try version 12 yet, and just now I got informed with bad news,

new surprise!

of course customization was the most potential feature of erpnext among other closed source platforms and now it gets disabled.

This looks like you made lot of customisation and didn’t factor the concern of it conflicting with new changes. There is no way to control such conflict unless your part of changes gets pulled into core -and I know it’s lot of work to get PR merged in addition to having a good intentions of giving back.

Any idea why we can’t submit sales invoices. Getting time out after long time.

But it is submitting very fast If I submit other transactions type like purchase invoice, JV etc.

I do not understand why??

Any one have a clue?

Can you post your console logs or log file details relevant to this. It might go a long way with trying to assist you.

erpnext.controllers.accounts_controller.update_invoice_status
Error
{‘event’: u’daily’, ‘retry’: 0, ‘log’: <function log at 0x7f7676617668>, ‘site’: u’myacc5.local’, ‘job_name’: u’erpnext.controllers.accounts_controller.update_invoice_status’, ‘method_name’: u’erpnext.controllers.accounts_controller.update_invoice_status’, ‘method’: <function update_invoice_status at 0x7f767650d230>, ‘user’: u’Administrator’, ‘kwargs’: {}, ‘is_async’: True}
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 103, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py”, line 1028, in update_invoice_status
where due_date < CURDATE() and docstatus = 1 and outstanding_amount > 0""")
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 214, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
OperationalError: (1213, u’Deadlock found when trying to get lock; try restarting transaction’)

From your logs, it appears as if the deadlock is happening on the update

update_invoice_status
where due_date < CURDATE() and docstatus = 1 and outstanding_amount > 0

You should probably log a bug report so the devs can have a look at it. However, to clear this error, you need to kill the query in mysql.

Log in as mysql admin (root) and run

    mysql > show processlist; 
    mysql > kill 12345; 

where 12345 is the process id of the update command.

1 Like

Do we have guide for this?

I am on Google cloud.

Do you have phpMyAdmin? If you open that and click the “status” button, you can see and kill deadlocked processes as crafter mentioned. If not, you have to log into the shell and typing “mysql” on the command line, logging in, and running those commands.

If you don’t want to deal with that, you can also restart mysqld, or even restart the entire database server, but that can be some serious downtime.

In the frappe-bench directory, run

bench mariadb
# or
# bench mysql

will this solved by restarting entire server ?

I have tried above and still the same.

I found below points.

I have created POS profile with series like " HU-SINV-YYYY;- "

I have save those invoices as draft.

Now I am using series like " HC-SINV-YYYY;- "

But the series starting from HU still in the naming series.

Problem is it is getting time out when I try to submit those both series invoices dated before one month.

but it is submitting both series in this month invoices.

So why is that happen?

I have restarted the server several times and nothing happen to fix this problem.

I am still fed up with this.

I am ready to compensate the one who willing to help me.

I can not submit sales invoices.

Title
frappe.model.delete_doc.delete_dynamic_links
Error
{‘event’: None, ‘retry’: 0, ‘log’: <function log at 0x7fa0d12bf668>, ‘site’: u’myacc5.local’, ‘job_name’: u’frappe.model.delete_doc.delete_dynamic_links’, ‘method_name’: u’frappe.model.delete_doc.delete_dynamic_links’, ‘method’: <function delete_dynamic_links at 0x7fa0d124f6e0>, ‘user’: u’admin@my-accountant.xyz’, ‘kwargs’: {‘doctype’: u’Supplier’, ‘name’: u’Rathmalkandura New !Quarry’}, ‘is_async’: True}
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 103, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 315, in delete_dynamic_links
and reference_name=%s""", (doctype, name))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 199, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
OperationalError: (1213, u’Deadlock found when trying to get lock; try restarting transaction’)

I have upgraded to V12 with same DB

Now getting this when I try to submit POS profile, submit sales previous sales invoices in draft, submitting purchase invoice for certain items, can not make stock issues to some items etc…

It is happening when we submit back dated sales invoices on September.

The thing is it is submitting for October and November without any issue.