DB Error: Too many writes in one request


I have a scheduler process which runs periodically and inserts records into the Item table. It was working fine until recently I started getting the error below:

2017-06-13 00:11:10,998: ERROR/MainProcess] Task frappe.tasks.scheduler_task[7d580587-5bfb-4a98-be59-a9fed6b9ca55] raised unexpected: ValidationError(u’Too many writes in one request. Please send smaller requests’,)

I have seen posts regarding the same issue which were fixed by the team.
Was wondering if this could this be an issue with the framework or how do I send smaller requests?

Here are the last few lines of the trace:
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py”, line 202, in save
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 224, in db_update
), d.values() + [d.get(“name”)])
File “/home/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 82, in sql
File “/home/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 179, in check_transaction_status
frappe.throw(_(“Too many writes in one request. Please send smaller requests”), frappe.ValidationError)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 202, in throw
msgprint(msg, raise_exception=exc)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 199, in msgprint
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 183, in _raise_exception
raise raise_exception, msg
ValidationError: Too many writes in one request. Please send smaller requests

Do your commits in batches. Rather than doing your commit at the end of the transaction, every 10 or 100 rows, do a db.commit.

I am not doing any commits in my code. I guess the framework would take
care of that.

The framework will commit at the end if you’re not doing commits yourself.

If thats the case, you’ll want to add your own db.commit for every 10 or 100 or so lines.