Error While Updating ERPNext V8

Hi,
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)
INFO:bench.app:pulling 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
    INFO:bench.app:pulling 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)
    Success
    Executing frappe.patches.v8_0.update_global_search_table in site1.local (1bd3e0294da19198)
    Success
    Executing frappe.patches.v7_2.remove_in_filter in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘doctype’, force=True) #2017-03-09 in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-03-03 in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2017-03-03 in site1.local (1bd3e0294da19198)
    Success
    Executing frappe.patches.v8_0.drop_is_custom_from_docperm in site1.local (1bd3e0294da19198)
    Success
    Executing frappe.patches.v8_0.drop_in_dialog in site1.local (1bd3e0294da19198)
    Success
    Executing frappe.patches.v8_0.update_records_in_global_search in site1.local (1bd3e0294da19198)
    Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
    main()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, 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/core.py”, 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/core.py”, line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 210, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
    frappe.modules.patch_handler.run_all()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
    if not run_single(patchmodule = patch):
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 89, in execute_patch
    frappe.db.rollback()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 737, in rollback
    self.sql(“rollback”)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 149, in sql
    self._cursor.execute(query)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
    self.errorhandler(self, exc, value)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
    raise errorclass, errorvalue
    _mysql_exceptions.OperationalError: (2006, ‘MySQL server has gone away’)
    ubuntu@ip-172-26-12-170:/home/frappe/frappe-bench$

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?

Regards
Ruchin Sharma

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

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

Regards
Ruchin Sharma

@ruchin78

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.

Regards
Ruchin Sharma

@ruchin78

Which Ubuntu are you running Frappe/ERPNext on?

Hi @saids
I am using Ubuntu 16.04LTS

Regards
Ruchin Sharma

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

@saidsl

@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.

Regards
Ruchin Sharma

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

@nabinhait
I have only these 4 patches in my patches.txt under frappe/frappe-bench folder. Which one I should comment or delete?
bench.patches.v3.deprecate_old_config
bench.patches.v3.celery_to_rq
bench.patches.v3.redis_bind_ip
bench.patches.v4.update_node

Regards
Ruchin Sharma

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

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

Regards
Ruchin Sharma

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

@saidsl
Yes, I did.

Regards
Ruchin Sharma

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

Regards
Ruchin Sharma

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

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