[SOLVED] Bench update error (never get such error before)

Hi all,

Today, i decide to do bench update (i did that everyday, no issues until today).

ericmachine@ericmachine-VirtualBox:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.app:pulling erpnext
From https://github.com/frappe/erpnext
 * branch            master     -> FETCH_HEAD
Already up-to-date.
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
Migrating meeting.dev
Updating frappe                     : [========================================]
Updating meeting                    : [========================================]
Migrating library
Updating frappe                     : [========================================]
Migrating mysite
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, 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/ericmachine/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ericmachine/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/ericmachine/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/ericmachine/frappe-bench/apps/frappe/frappe/commands.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/commands.py", line 205, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/migrate.py", line 27, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 21, in run_all
    executed = [p[0] for p in frappe.db.sql("""select patch from `tabPatch Log`""")]
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/database.py", line 106, in sql
    self.connect()
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/database.py", line 63, in connect
    self.use(self.user)
  File "/home/ericmachine/frappe-bench/apps/frappe/frappe/database.py", line 68, in use
    self._conn.select_db(db_name)
_mysql_exceptions.OperationalError: (1049, "Unknown database 'b7b324d548'")
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==3.0.0', 'console_scripts', 'bench')()
  File "/home/ericmachine/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/ericmachine/bench-repo/bench/commands/update.py", line 61, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/ericmachine/bench-repo/bench/commands/update.py", line 91, in _update
    patch_sites(bench=bench_path)
  File "/home/ericmachine/bench-repo/bench/utils.py", line 131, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/ericmachine/bench-repo/bench/utils.py", line 468, in run_frappe_cmd
    raise CommandFailedError(args)
bench.utils.CommandFailedError: ('--site', 'all', 'migrate')

Any idea what’s wrong and how should I fix this issue?

Any help? Thanks.

Hi @ericmachine88,

Did you created new site mysite, this site has database b7b324d548 which is not exist.
Check your databases list.

Thanks, Rohit

1 Like

oh, i think i drop that database yesterday.

so how do i remove mysite? just remove the folder “rm -R mysite” will do? or is there a bench command to do that?

it seems have to remove manually as stated here

Hi @ericmachine88,

Yup, run command rm -r mysite.

Thanks, Rohit

1 Like

amazing, it works :slight_smile:

just curious, is it okay to run “bench update” at production database to keep the codebase updated. In Odoo, I recall even if I do a git pull, i still have to manually migrate it. I think erpnext will auto-migrate for me. is this too risky?

or is it better i test on staging first and once all good only run such command in production.

How do you guys handle it?

thanks :slight_smile:

Hi @ericmachine88,

Yup work on first staging site, if it works then go for production.

Thanks, Rohit

Hi, just for information’s sake, the best way to remove a site is bench drop-site [sitename]

This will remove the site folder and the database as well.

1 Like

thanks :slight_smile: