Guide: Rename a docype with a large number of transactions

This morning I had to do something simple, rename a company. I didnt think this would take me 2 and a half hours. So I’m posting this for anyone who encounters the same issue.

My solution was a hack because ERPNext (Nginx and Mysql) kept timing out. Frappe also has a hard limit of 200k transactions per rename request like below

Too many requests (Frappe)


Request Timed Out (Nginx)

So this is what I did

Warning!!!: backup your configs and restore them after making these changes. Any loss resulting from this guide is on you.

1. Increase Frappe limit from 200k to 1Mil (?)

frappe/database.py at 3e232625c0af570ff6dd8aa2c851e75e28b3cff9 · frappe/frappe · GitHub

2. Increase Nginx Timeout

Update bench config

bench config http_timeout <integer> #mine was like 100000

bench setup supervisor

bench setup nginx

Restart services (as root)

sudo supervisorctl reload

sudo service nginx reload

3. Increase MySQL timeout

connect_timeout = 5 # to 10000
wait_timeout = 6000 # to 60000

sudo nano sudo vim /etc/mysql/my.cnf
sudo service mysql restart

4. Try your rename and pray for the best.

5. Restore your old / optimal settings

Nginx timeout settings can be found in <bench-dir>/sites/common_site_config.json. just remove that line and do the reloads according to step 2.

Note: Now some of these numbers and steps might not be necessary and I don’t mind some suggestions to minimize this guide. The point is that this worked for me.

6 Likes

Thanks for the detailed post @adam26d

If we make 200k write limit configurable in Frappe, it would make it easy for users to change this limit.

1 Like