Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymysql.err.OperationalError: (1050, "Table 'tabLMS Exercise' already exists") #486

Closed
muchai opened this issue Mar 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@muchai
Copy link

muchai commented Mar 8, 2023

Happens during update to the latest ERPNext v14.18.1 and Frappe v14.26.4

Migrating navari-ltd.frappe.cloud
Executing lms.patches.v0_0.set_member_in_progress #3-03-2023 in navari-ltd.frappe.cloud (_87cbb1ab8b195872)
Success: Done in 0.094s
Executing lms.patches.v0_0.rename_exercise_doctype in navari-ltd.frappe.cloud (_87cbb1ab8b195872)
Building search index for navari-ltd.frappe.cloud
Retrieving Routes : [ ] 1%

Traceback with variables (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
mod_name = 'frappe.utils.bench_helper'
alter_argv = True
mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py')
code = <code object at 0x7f84e4c9d160, file "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 1>
main_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'click': <m...
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
code = <code object at 0x7f84e4c9d160, file "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 1>
run_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'click': <m...
init_globals = None
mod_name = 'main'
mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>, origin='/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py')
pkg_name = 'frappe.utils'
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f84e5c4c2e0>
fname = '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'
cached = '/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc'
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in
main()
...skipped... 25 vars
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
click.Group(commands=commands)(prog_name="bench")
commands = {'frappe': , 'get-frappe-commands': , 'get-frappe-help': }
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
self =
args = ()
kwargs = {'prog_name': 'bench'}
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
self =
args = ['frappe', '--site', 'navari-ltd.frappe.cloud', 'migrate']
prog_name = 'bench'
complete_var = None
standalone_mode = True
extra = {}
ctx = <click.core.Context object at 0x7f84e5e23760>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f84e4ca0ca0>
args = ['migrate']
cmd_name = 'frappe'
cmd =
sub_ctx = <click.core.Context object at 0x7f84e4c87cd0>
ctx = <click.core.Context object at 0x7f84e5e23760>
self =
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f84e4b4b010>
args = []
cmd_name = 'migrate'
cmd =
sub_ctx = <click.core.Context object at 0x7f84e4b51690>
ctx = <click.core.Context object at 0x7f84e4c87cd0>
self =
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
self =
ctx = <click.core.Context object at 0x7f84e4b51690>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
self = <click.core.Context object at 0x7f84e4b51690>
callback = <function migrate at 0x7f84e4aef6d0>
ctx = <click.core.Context object at 0x7f84e4b51690>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
f = <function migrate at 0x7f84e4aef490>
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py", line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
ctx = <click.core.Context object at 0x7f84e4b51690>
args = ()
kwargs = {'skip_failing': False, 'skip_search_index': False}
profile = False
f = <function migrate at 0x7f84e4aef400>
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 557, in migrate
SiteMigration(
context = {'sites': ['navari-ltd.frappe.cloud'], 'force': False, 'verbose': False, 'profile': False}
skip_failing = False
skip_search_index = False
activate_by_import = <module 'traceback_with_variables.activate_by_import' from '/home/frappe/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py'>
SiteMigration = <class 'frappe.migrate.SiteMigration'>
site = 'navari-ltd.frappe.cloud'
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 175, in run
self.run_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7f84e4b518d0>
site = 'navari-ltd.frappe.cloud'
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 41, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7f84e4b518d0>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x7f84df5f4d30>
File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 110, in run_schema_updates
frappe.modules.patch_handler.run_all(
self = <frappe.migrate.SiteMigration object at 0x7f84e4b518d0>
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 75, in run_all
run_patch(patch)
patch_type = <PatchType.pre_model_sync: 'pre_model_sync'>
executed = {'erpnext.patches.v12_0.move_target_distribution_from_parent_to_child', 'erpnext.patches.v13_0.update_job_card_status', 'erpnext.patches.v11_0.update_sales_partner_type', 'frappe.patches.v8_1.enable_allow_error_traceback_in_system_settings', 'frappe.patches.v7_2.fix_email_queue_recipient', 'frappedesk.patches.add_description_for_tickets_created_via_email', 'frappe.patches.v8_0.rename_print_to_printing', 'execute:frappe.delete_doc("DocType", "LMS Message")', 'erpnext.patches.v7_0.fix_duplicate_icons', 'erpnext.patches.v13_0.shopping_cart_to_ecommerce', 'frappe.patches.v4_0.add_delete_permission', 'frappedesk.patches.create_frappedesk_comments_from_ticket_comments', 'execute:frappe.delete_doc("DocType", "LMS Topic") #6-10-2021', 'erpnext.patches.v14_0.restore_einvoice_fields', 'erpnext.patches.v13_0.update_sla_enhancements', 'frappe.patches.v13_0.add_toggle_width_in_navbar_settings', 'execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")', 'erpnext.patches.v4_0.val...
run_patch = <function run_all..run_patch at 0x7f84df102200>
patches = ['frappe.patches.v12_0.remove_deprecated_fields_from_doctype #3', 'execute:frappe.utils.global_search.setup_global_search_table()', "execute:frappe.reload_doc('core', 'doctype', 'doctype_action', force=True) #2019-09-23", "execute:frappe.reload_doc('core', 'doctype', 'doctype_link', force=True) #2020-10-17", "execute:frappe.reload_doc('core', 'doctype', 'doctype_state', force=True) #2021-12-15", "execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2017-09-22", "execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2018-02-20", 'frappe.patches.v11_0.drop_column_apply_user_permissions', "execute:frappe.reload_doc('core', 'doctype', 'custom_docperm')", "execute:frappe.reload_doc('core', 'doctype', 'docperm') #2018-05-29", "execute:frappe.reload_doc('core', 'doctype', 'comment')", "execute:frappe.reload_doc('core', 'doctype', 'document_naming_rule', force=True)", "execute:frappe.reload_doc('core', 'doctype', 'module_def') #2020-08-28", "execute:frappe.reloa...
patch = 'lms.patches.v0_0.rename_exercise_doctype'
skip_failing = False
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 62, in run_patch
if not run_single(patchmodule=patch):
patch = 'lms.patches.v0_0.rename_exercise_doctype'
skip_failing = False
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 150, in run_single
return execute_patch(patchmodule, method, methodargs)
patchmodule = 'lms.patches.v0_0.rename_exercise_doctype'
method = None
methodargs = None
force = False
conf =
File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 186, in execute_patch
_patch()
patchmodule = 'lms.patches.v0_0.rename_exercise_doctype'
method = None
methodargs = None
has_patch_file = True
patch = 'lms.patches.v0_0.rename_exercise_doctype.execute'
docstring = ''
_patch = <function execute at 0x7f84df1028c0>
start_time = 1678213756.3846354
File "/home/frappe/frappe-bench/apps/lms/lms/patches/v0_0/rename_exercise_doctype.py", line 10, in execute
rename_doc("DocType", "Exercise", "LMS Exercise")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/rename_doc.py", line 195, in rename_doc
new_doc.run_method("after_rename", old, new, merge)
doctype = 'DocType'
old = 'Exercise'
new = 'LMS Exercise'
force = False
merge = False
ignore_permissions = False
ignore_if_exists = False
show_alert = True
rebuild_search = True
doc = None
validate = True
old_usage_style = 'LMS Exercise'
new_usage_style = None
meta = <Meta: DocType>
old_doc = <DocType: Exercise>
out = {}
link_fields = [{'parent': 'Sales Invoice Advance', 'fieldname': 'reference_type', 'issingle': 0}, {'parent': 'Party Link', 'fieldname': 'primary_role', 'issingle': 0}, {'parent': 'Email Queue', 'fieldname': 'reference_doctype', 'issingle': 0}, {'parent': 'Notification Log', 'fieldname': 'document_type', 'issingle': 0}, {'parent': 'Logs To Clear', 'fieldname': 'ref_doctype', 'issingle': 0}, {'parent': 'Data Export', 'fieldname': 'reference_doctype', 'issingle': 1}, {'parent': 'Party Link', 'fieldname': 'secondary_role', 'issingle': 0}, {'parent': 'Advance Tax', 'fieldname': 'reference_type', 'issingle': 0}, {'parent': 'Repost Item Valuation', 'fieldname': 'voucher_type', 'issingle': 0}, {'parent': 'Closed Document', 'fieldname': 'document_type', 'issingle': 0}, {'parent': 'Assignment Rule', 'fieldname': 'document_type', 'issingle': 0}, {'parent': 'Payment Request', 'fieldname': 'reference_doctype', 'issingle': 0}, {'parent': 'Serial No', 'fieldname': 'delivery_document_type', 'issingle': 0}, {'parent...
new_doc = <DocType: LMS Exercise>
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 909, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
self = <DocType: LMS Exercise>
args = ('Exercise', 'LMS Exercise', False)
kwargs = {}
fn = <function Document.run_method..fn at 0x7f84debe7370>
method = 'after_rename'
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1259, in composer
return composed(self, method, args, **kwargs)
self = <DocType: LMS Exercise>
args = ('Exercise', 'LMS Exercise', False)
kwargs = {}
hooks = [<function clear_doctype_notifications at 0x7f84e4c5dea0>]
method = 'after_rename'
doc_events = {'
': {'after_insert': ['frappe.event_streaming.doctype.event_update_log.event_update_log.notify_consumers'], 'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.core.doctype.activity_log.feed.update_feed', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.event_streaming.doctype.event_update_log.event_update_log.notify_consumers', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.event_streaming.doctype.event_update_log.event_update_log.notify_co...
handler = 'frappe.desk.notifications.clear_doctype_notifications'
composed = <function Document.hook..compose..runner at 0x7f84debe6f80>
compose = <function Document.hook..compose at 0x7f84debe63b0>
f = <function Document.run_method..fn at 0x7f84debe7370>
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1241, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
self = <DocType: LMS Exercise>
method = 'after_rename'
args = ('Exercise', 'LMS Exercise', False)
kwargs = {}
add_to_return_value = <function Document.hook..add_to_return_value at 0x7f84debe6950>
fn = <function Document.run_method..fn at 0x7f84debe7370>
hooks = (<function clear_doctype_notifications at 0x7f84e4c5dea0>,)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 906, in fn
return method_object(*args, **kwargs)
self = <DocType: LMS Exercise>
args = ('Exercise', 'LMS Exercise', False)
kwargs = {}
method_object = <bound method DocType.after_rename of <DocType: LMS Exercise>>
method = 'after_rename'
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 520, in after_rename
frappe.db.rename_table(old, new)
self = <DocType: LMS Exercise>
old = 'Exercise'
new = 'LMS Exercise'
merge = False
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 239, in rename_table
return self.sql(f"RENAME TABLE {old_name} TO {new_name}")
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7f84df5c7a60>
old_name = 'tabExercise'
new_name = 'tabLMS Exercise'
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 219, in sql
self._cursor.execute(query, values)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7f84df5c7a60>
query = 'RENAME TABLE tabExercise TO tabLMS Exercise'
values = None
as_dict = 0
as_list = 0
formatted = 0
debug = False
ignore_ddl = 0
as_utf8 = 0
auto_commit = 0
update = None
explain = False
run = True
pluck = False
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
result = self._query(query)
self = <pymysql.cursors.Cursor object at 0x7f84df46a0b0>
query = 'RENAME TABLE tabExercise TO tabLMS Exercise'
args = None
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
conn.query(q)
self = <pymysql.cursors.Cursor object at 0x7f84df46a0b0>
q = 'RENAME TABLE tabExercise TO tabLMS Exercise'
conn = <pymysql.connections.Connection object at 0x7f84df469ff0>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
self = <pymysql.connections.Connection object at 0x7f84df469ff0>
sql = b'RENAME TABLE tabExercise TO tabLMS Exercise'
unbuffered = False
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
result.read()
self = <pymysql.connections.Connection object at 0x7f84df469ff0>
unbuffered = False
result = <pymysql.connections.MySQLResult object at 0x7f84df166530>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
first_packet = self.connection._read_packet()
self = <pymysql.connections.MySQLResult object at 0x7f84df166530>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
packet.raise_for_error()
self = <pymysql.connections.Connection object at 0x7f84df469ff0>
packet_type = <class 'pymysql.protocol.MysqlPacket'>
buff = bytearray(b"\xff\x1a\x04#42S01Table 'tabLMS Exercise' already exists")
packet_header = b'/\x00\x00\x01'
btrl = 47
btrh = 0
packet_number = 1
bytes_to_read = 47
recv_data = b"\xff\x1a\x04#42S01Table 'tabLMS Exercise' already exists"
packet = <pymysql.protocol.MysqlPacket object at 0x7f84deb4ba90>
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
self = <pymysql.protocol.MysqlPacket object at 0x7f84deb4ba90>
errno = 1050
File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
raise errorclass(errno, errval)
data = b"\xff\x1a\x04#42S01Table 'tabLMS Exercise' already exists"
errno = 1050
errval = "Table 'tabLMS Exercise' already exists"
errorclass = <class 'pymysql.err.OperationalError'>
pymysql.err.OperationalError: (1050, "Table 'tabLMS Exercise' already exists")

@muchai muchai added the bug Something isn't working label Mar 8, 2023
@pateljannat
Copy link
Collaborator

pateljannat commented Mar 14, 2023

Did you make any changes to the Exercise doctype before the update?

I am unable to replicate the issue on any of my sites.

Can you try updating by skipping failing patches?

bench --site migrate --skip-failing

@muchai
Copy link
Author

muchai commented Mar 15, 2023

This is resolved now. Thank you.

@muchai muchai closed this as completed Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants