Error on upgrade - This statement can cause implicit commit

Traceback (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,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1442, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1363, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1830, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1830, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py", line 681, in migrate
    SiteMigration(
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py", line 188, in run
    self.run_schema_updates()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py", line 52, in wrapper
    raise e
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py", line 44, in wrapper
    ret = method(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py", line 121, in run_schema_updates
    frappe.modules.patch_handler.run_all(
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 76, in run_all
    run_patch(patch)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 62, in run_patch
    if not run_single(patchmodule=patch):
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 152, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 179, in execute_patch
    frappe.db.begin()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/database/database.py", line 1166, in begin
    self.sql(f"START TRANSACTION {mode}")
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/database/database.py", line 210, in sql
    self.check_transaction_status(query)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/database/database.py", line 419, in check_transaction_status
    self.check_implicit_commit(query)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/database/database.py", line 440, in check_implicit_commit
    raise ImplicitCommitError("This statement can cause implicit commit")
frappe.exceptions.ImplicitCommitError: This statement can cause implicit commit