Error While Updating ERPNext V8

While updating ERPNext, I am getting the below error:

ubuntu@ip-172-26-12-170:/home/frappe/frappe-bench$ sudo bench update --upgrade
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
Requirement already satisfied: olefile in ./env/lib/python2.7/site-packages (from Pillow) frappe
INFO:bench.utils:git pull upstream master
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript

  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete erpnext
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    Updating Python libraries…
    INFO:bench.utils:./env/bin/pip install --upgrade pip
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    INFO:bench.utils:./env/bin/pip install -q -r /home/frappe/.bench/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/library/requirements.txt
    Backing up sites…
    Patching sites…
    Migrating library
    Updating DocTypes for frappe : [========================================]
    Syncing help database…
    Migrating site1.local
    Executing execute:frappe.utils.global_search.setup_global_search_table() in site1.local (1bd3e0294da19198)
    Executing frappe.patches.v8_0.update_global_search_table in site1.local (1bd3e0294da19198)
    Executing frappe.patches.v7_2.remove_in_filter in site1.local (1bd3e0294da19198)
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘doctype’, force=True) #2017-03-09 in site1.local (1bd3e0294da19198)
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-03-03 in site1.local (1bd3e0294da19198)
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2017-03-03 in site1.local (1bd3e0294da19198)
    Executing frappe.patches.v8_0.drop_is_custom_from_docperm in site1.local (1bd3e0294da19198)
    Executing frappe.patches.v8_0.drop_in_dialog in site1.local (1bd3e0294da19198)
    Executing frappe.patches.v8_0.update_records_in_global_search in site1.local (1bd3e0294da19198)
    Traceback (most recent call last):
    File “/usr/lib/python2.7/”, line 174, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 79, in
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 16, in main
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 722, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 697, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 535, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/”, line 210, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 31, in migrate
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 29, in run_all
    if not run_single(patchmodule = patch):
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 89, in execute_patch
    File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 737, in rollback
    File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 149, in sql
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/”, line 205, in execute
    self.errorhandler(self, exc, value)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/”, line 36, in defaulterrorhandler
    raise errorclass, errorvalue
    _mysql_exceptions.OperationalError: (2006, ‘MySQL server has gone away’)

I tried:
sudo service mysql stop
sudo service mysql start

and after that whenever I do an update I get the same error.

Any idea about the error coming?

Ruchin Sharma

Can you run a bench mysql command to see if bench can access the database?

Yes, I have checked that, it is working fine.

Ruchin Sharma


Based on the error you have, this might help you resolve the issue

Hi @saidsl
Many thanks for your inputs but I have already tried it and it didn’t work for me.

Ruchin Sharma


Which Ubuntu are you running Frappe/ERPNext on?

Hi @saids
I am using Ubuntu 16.04LTS

Ruchin Sharma

@ruchin78 How much memory do you have allocated to the server?


@all The patch update_records_in_global_search takes huge time, I am refactoring the patch to decrease the time, it should be done by the end of the today. After that the error will go away automatically. For now you can skip the patch by commenting it or deleting it from patches.txt.

I think the error is coming because of “max_allowed_packets” set in your mysql config. Try to set it to a higher number.

Hi @nabinhait
Thanks for your feedback, I already increase the max_allowed_packets from 16M to 20M but it is still not working.
Recently I creased the connection timeout to get rid-off this issue, so that it doesn’t not timeout the connection very early.

After resetting the connection time out, I have started updating the same and it is still under process, will update you about the outcome of the same.

Edit: After resetting the connection timeout from 5 to 50 still getting the same error. Hope it will get fixed soon.

Ruchin Sharma

May be try to set a much higher value like 128M

I have only these 4 patches in my patches.txt under frappe/frappe-bench folder. Which one I should comment or delete?

Ruchin Sharma

Comment out the update_records_in_global_search patch from apps/frappe/frappe/patches.txt

I tried after resetting the
max_allowed_packets from 20M to 128M
But still the error persist.

Ruchin Sharma

@ruchin78 – Am pretty sure you would have rebooted the server after making all those changes right? or/and restart mysql?

Yes, I did.

Ruchin Sharma

I have deleted the line from the patches.txt and after that when I am trying to update, I am getting below error:

Ruchin Sharma

ok, then run bench --site all migrate instead of bench update

After doing everything, I ran the below command
bench --site all migrate
and got the below error: