Database issues on last bench update

Hi,

I got this error on last update, but have just also had some problems with MariaDB after update to last version, so maybe this is not related with ERPNext?!

Executing erpnext.patches.v5_0.project_costing in site1.local (1bd3e0294d)
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/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 77, in <module>
    main()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 14, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands.py", line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands.py", line 202, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/patches/v5_0/project_costing.py", line 4, in execute
    frappe.reload_doctype("Project")
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 526, in reload_doctype
    reload_doc(scrub(db.get_value("DocType", doctype, "module")), "doctype", scrub(doctype))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 538, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/__init__.py", line 37, in reload_doc
    return import_files(module, dt, dn, force=force)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 17, in import_files
    return import_file(module, dt, dn, force=force)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 22, in import_file
    ret = import_file_by_path(path, force)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 54, in import_file_by_path
    import_doc(doc, force=force, data_import=data_import)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 120, in import_doc
    doc.insert()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 194, in insert
    self.run_post_save_methods()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 558, in run_post_save_methods
    self.run_method("on_update")
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 506, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 619, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 602, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 500, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 102, in on_update
    updatedb(self.name)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_schema.py", line 62, in updatedb
    tab.sync()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_schema.py", line 88, in sync
    self.alter()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_schema.py", line 237, in alter
    frappe.db.sql("alter table `{}` {}".format(self.name, ", ".join(query)))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database.py", line 143, in sql
    self._cursor.execute(query)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/erpnext/bench-repo/bench/cli.py", line 55, in cli
    bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/erpnext/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/erpnext/bench-repo/bench/utils.py", line 118, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/erpnext/bench-repo/bench/utils.py", line 427, in run_frappe_cmd
    subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
  File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('/home/erpnext/frappe-bench/env/bin/python', '-m', 'frappe.utils.bench_helper', 'frappe', '--site', 'all', 'migrate')' returned non-zero exit status 1

I am using ERPNext with MariaDB 5.5. Can ERPNext be used with version 10 of this db? Does it have any advantages if it is possible?

Many thanks and kind regards,

Do you happen to have a lot of custom fields on this table?

Also with version 5, we forced innodb_large_prefix and that should increase the limit to 3072 bytes. Did you install v5 from scratch or did you upgrade?

Hi Pratik,

Many thanks for your reply.

I upgraded from v5.

Thanks and regards,

Hi,

What table is it? Project Costing?

No I don’t have. Just one in Task table.

Thanks and regards,

Hi Pratik,

Many thanks for this.

With what you say, I remembered that I had implemented those changes in mysql.cnf file when I upgraded, and now they were not on the file any more.

So mysql.cnf file must have been modified with the problem I had mith MariaDB, and now that I put back those changes on the file I could finish the update of the bench withour any problem.

Many thanks for that!! And kind regards from Spain,

Alberto

1 Like

Exactly same error,
@pagliaso Can you brief how did you solve it?

Hi Nitto,

My problem came from loosing the MySql/MariaDB config file I had. When I restored those settings everything came back to normal.

The settings were:

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

So you will need to add this to your MariaDB config file in the corresponding sections. After that you might need to restart the database and do bench update again.

On my server this file was located in /etc/mysql/my.cnf

This thread also talks about it:

https://discuss.frappe.io/t/1709-index-column-size-too-large-the-maximum-column-size-is-767-bytes-when-trying-to-restore-automated-backup/6026

I hope this helps. Kind regards from Spain,

Alberto