Update site migrate fails all the time

hello guys,
i’m new here, someone please help me with the error –
Update site migrate fails all the time when i try to update the production site, it shows`Migrating rawscholar1.frappe.cloud
Updating DocTypes for frappe : [========================================] 100%
Updating DocTypes for rawscholar : [========================================] 100%

Traceback with variables (most recent call last):
File “”, line 198, in _run_module_as_main
mod_name = ‘frappe.utils.bench_helper’
alter_argv = True
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa5d2b83310>, origin=‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
code = <code object at 0xcb5e80, 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 0x7fa5d2b83310>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa5d2b83310>, 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-311.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.11/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.11/json/init.py’>, ‘os’: <module ‘os’ (frozen)>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.11/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.11/warnings.py’>, ‘Path’: <class ‘pathlib.Path’>, ‘de…
File “”, line 88, in _run_code
code = <code object at 0xcb5e80, 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 0x7fa5d2b83310>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa5d2b83310>, 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-311.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.11/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.11/json/init.py’>, ‘os’: <module ‘os’ (frozen)>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.11/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.11/warnings.py’>, ‘Path’: <class ‘pathlib.Path’>, ‘de…
init_globals = None
mod_name = ‘main
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa5d2b83310>, 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 0x7fa5d2b83310>
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-311.pyc’
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 114, in
main()
…skipped… 27 vars
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 20, 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.11/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
self =
args = ()
kwargs = {‘prog_name’: ‘bench’}
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
self =
args = [‘frappe’, ‘–site’, ‘rawscholar1.frappe.cloud’, ‘migrate’, ‘–skip-search-index’]
prog_name = ‘bench’
complete_var = None
standalone_mode = True
windows_expand_args = True
extra = {}
ctx = <click.core.Context object at 0x7fa5d1654210>
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
self =
ctx = <click.core.Context object at 0x7fa5d1654210>
_process_result = <function MultiCommand.invoke.._process_result at 0x7fa5d1ca4e00>
args = [‘migrate’, ‘–skip-search-index’]
cmd_name = ‘frappe’
cmd =
sub_ctx = <click.core.Context object at 0x7fa5d1c8f350>
class = <class ‘click.core.MultiCommand’>
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
self =
ctx = <click.core.Context object at 0x7fa5d1c8f350>
_process_result = <function MultiCommand.invoke.._process_result at 0x7fa5d1ca4d60>
args =
cmd_name = ‘migrate’
cmd =
sub_ctx = <click.core.Context object at 0x7fa5d1654650>
class = <class ‘click.core.MultiCommand’>
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
self =
ctx = <click.core.Context object at 0x7fa5d1654650>
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
_Context__self = <click.core.Context object at 0x7fa5d1654650>
_Context__callback = <function migrate at 0x7fa5d15fae80>
args = ()
kwargs = {‘skip_search_index’: True, ‘skip_failing’: False}
ctx = <click.core.Context object at 0x7fa5d1654650>
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py”, line 33, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {‘skip_search_index’: True, ‘skip_failing’: False}
f = <function migrate at 0x7fa5d15fac00>
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 0x7fa5d1654650>
args = ()
kwargs = {‘skip_search_index’: True, ‘skip_failing’: False}
profile = False
f = <function migrate at 0x7fa5d15fab60>
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 616, in migrate
).run(site=site)
context = {‘sites’: [‘rawscholar1.frappe.cloud’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
skip_failing = False
skip_search_index = True
activate_by_import = <module ‘traceback_with_variables.activate_by_import’ from ‘/home/frappe/frappe-bench/env/lib/python3.11/site-packages/traceback_with_variables/activate_by_import.py’>
SiteMigration = <class ‘frappe.migrate.SiteMigration’>
site = ‘rawscholar1.frappe.cloud’
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 187, in run
self.post_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7fa5cf6d9a50>
site = ‘rawscholar1.frappe.cloud’
filelock = <function filelock at 0x7fa5cf3f4f40>
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 52, in wrapper
raise e
args = (<frappe.migrate.SiteMigration object at 0x7fa5cf6d9a50>,)
kwargs = {}
method = <function SiteMigration.post_schema_updates at 0x7fa5cf3f4ae0>
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 44, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7fa5cf6d9a50>,)
kwargs = {}
method = <function SiteMigration.post_schema_updates at 0x7fa5cf3f4ae0>
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 140, in post_schema_updates
sync_fixtures()
self = <frappe.migrate.SiteMigration object at 0x7fa5cf6d9a50>
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/fixtures.py”, line 22, in sync_fixtures
import_fixtures(app)
app = ‘rawscholar’
apps = [‘frappe’, ‘rawscholar’]
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/fixtures.py”, line 41, in import_fixtures
import_doc(file_path)
app = ‘rawscholar’
fixtures_path = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures’
fixture_files = [‘courses.json’, ‘workspace.json’, ‘number_card.json’, ‘attachment_type.json’, ‘custom_docperm.json’, ‘countries.json’, ‘qualification_type.json’, ‘role.json’, ‘university.json’]
fname = ‘courses.json’
file_path = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/data_import/data_import.py”, line 265, in import_doc
import_file_by_path(
path = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’
pre_process = None
files = [‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’]
f = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 146, in import_file_by_path
import_doc(
path = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’
force = True
data_import = True
pre_process = None
ignore_version = None
reset_permissions = True
docs = [{‘branch’: ‘Dental Anatomy’, ‘course’: ‘Dental Nursing’, ‘docstatus’: 0, ‘doctype’: ‘Courses’, ‘duration’: ‘24 Months’, ‘exam_accepted’: None, ‘fee’: ‘₹12.37 L/yr’, ‘level’: ‘Diploma’, ‘mode’: ‘Full time’, ‘modified’: ‘2024-06-18 13:53:55.754267’, ‘name’: ‘COR-0001’, ‘university’: ‘Trinity College Dublin’, ‘__islocal’: 1}, {‘branch’: ‘History’, ‘course’: ‘BA Hons History of Art and Architecture JH’, ‘docstatus’: 0, ‘doctype’: ‘Courses’, ‘duration’: ‘48 Months’, ‘exam_accepted’: None, ‘fee’: ‘₹18.00 L/yr’, ‘level’: ‘UG’, ‘mode’: ‘Full time’, ‘modified’: ‘2024-06-18 13:53:55.816026’, ‘name’: ‘COR-0002’, ‘university’: ‘Trinity College Dublin’, ‘__islocal’: 1}, {‘branch’: ‘Foreign Language’, ‘course’: ‘BA Hons German JH’, ‘docstatus’: 0, ‘doctype’: ‘Courses’, ‘duration’: ‘48 Months’, ‘exam_accepted’: None, ‘fee’: ‘₹18.51 L/yr’, ‘level’: ‘UG’, ‘mode’: ‘Full time’, ‘modified’: ‘2024-06-18 13:53:55.944796’, ‘name’: ‘COR-0003’, ‘university’: ‘Trinity College Dublin’, ‘__islocal’: 1}, {'branch…
calculated_hash = ‘c0b1d013cfaab6bcbdfdd259923e5a73’
doc = {‘branch’: ‘Graphic Designing’, ‘course’: ‘BA Graphic Communication’, ‘docstatus’: 0, ‘doctype’: ‘Courses’, ‘duration’: ‘36 Months’, ‘exam_accepted’: None, ‘fee’: ‘₹21.50 L/yr’, ‘level’: ‘UG’, ‘mode’: ‘Full time’, ‘modified’: ‘2024-06-20 16:52:46.424876’, ‘name’: ‘COR-33334’, ‘university’: ‘University of Reading, Reading’, ‘__islocal’: 1}
db_modified_timestamp = datetime.datetime(2024, 6, 20, 16, 52, 46, 424876)
is_db_timestamp_latest = True
new_modified_timestamp = ‘2024-06-20 16:52:46.243541’
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 231, in import_doc
delete_old_doc(doc, reset_permissions)
docdict = {‘branch’: ‘Graphic Designing’, ‘course’: ‘BA Graphic Communication’, ‘docstatus’: 0, ‘doctype’: ‘Courses’, ‘duration’: ‘36 Months’, ‘exam_accepted’: None, ‘fee’: ‘₹21.50 L/yr’, ‘level’: ‘UG’, ‘mode’: ‘Full time’, ‘modified’: ‘2024-06-20 16:52:46.424876’, ‘name’: ‘COR-33334’, ‘university’: ‘University of Reading, Reading’, ‘__islocal’: 1}
data_import = True
pre_process = None
ignore_version = None
reset_permissions = True
path = ‘/home/frappe/frappe-bench/apps/rawscholar/rawscholar/fixtures/courses.json’
controller = <class ‘rawscholar.rawscholar.doctype.courses.courses.Courses’>
doc = <Courses: COR-33334>
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 274, in delete_old_doc
frappe.delete_doc(doc.doctype, doc.name, force=1, ignore_doctypes=ignore, for_reload=True)
doc = <Courses: COR-33334>
reset_permissions = True
ignore =
old_doc = <Courses: COR-33334>
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1392, in delete_doc
return frappe.model.delete_doc.delete_doc(
doctype = ‘Courses’
name = ‘COR-33334’
force = 1
ignore_doctypes =
for_reload = True
ignore_permissions = False
flags = None
ignore_on_trash = False
ignore_missing = True
delete_permanently = False
…skipped… 1 vars
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 154, in delete_doc
delete_for_document(doc)
doctype = ‘Courses’
name = ‘COR-33334’
force = 1
ignore_doctypes =
for_reload = True
ignore_permissions = False
flags = None
ignore_on_trash = False
ignore_missing = True
delete_permanently = False
is_virtual = 0
names = [‘COR-33334’]
doc = <Courses: COR-33334>
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/global_search.py”, line 462, in delete_for_document
frappe.db.delete(“__global_search”, {“doctype”: doc.doctype, “name”: doc.name})
doc = <Courses: COR-33334>
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 1273, in delete
return query.run(**kwargs)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7fa5cf3ee350>
doctype = ‘__global_search’
filters = {‘doctype’: ‘Courses’, ‘name’: ‘COR-33334’}
debug = False
kwargs = {‘debug’: False}
query = DELETE FROM `__global_search` WHERE `doctype`=‘Courses’ AND `name`=‘COR-33334’
File “/home/frappe/frappe-bench/apps/frappe/frappe/query_builder/utils.py”, line 87, in execute_query
result = frappe.db.sql(query, params, *args, **kwargs) # nosemgrep
query = ‘DELETE FROM `__global_search` WHERE `doctype`=%(param1)s AND `name`=%(param2)s’
args = ()
kwargs = {‘debug’: False}
child_queries =
params = {‘param1’: ‘Courses’, ‘param2’: ‘COR-33334’}
execute_child_queries = <function patch_query_execute..execute_child_queries at 0x7fa5cf49a020>
prepare_query = <function patch_query_execute..prepare_query at 0x7fa5cf49a0c0>
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 214, in sql
self.check_transaction_status(query)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7fa5cf3ee350>
query = ‘DELETE FROM `__global_search` WHERE `doctype`=%(param1)s AND `name`=%(param2)s’
values = {‘param1’: ‘Courses’, ‘param2’: ‘COR-33334’}
as_dict = 0
as_list = 0
debug = False
ignore_ddl = 0
auto_commit = 0
update = None
explain = False
run = True
pluck = False
as_iterator = False
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 436, in check_transaction_status
raise frappe.TooManyWritesError(msg)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7fa5cf3ee350>
query = ‘DELETE FROM `__global_search` WHERE `doctype`=%(param1)s AND `name`=%(param2)s’
msg = ‘

Too many changes to database in single action.
The changes have been reverted.

frappe.exceptions.TooManyWritesError:

Too many changes to database in single action.
The changes have been reverted.
`

can anyone help me with this error

which command triggers such error in your terminal?
could you explain such in details?

actually this error is shown in the production site when i click ‘update available’.
this same error shows at the development side when i give the command bench migrate

anyone knows what to do??

def check_transaction_status(self, query):
“”“Raises exception if more than 200,000 INSERT, UPDATE queries are
executed in one transaction. This is to ensure that writes are always flushed otherwise this
could cause the system to hang.”“”
self.check_implicit_commit(query)

	if query and is_query_type(query, ("commit", "rollback")):
		self.transaction_writes = 0

	if query.lstrip()[:6].lower() in ("update", "insert", "delete"):
		self.transaction_writes += 1
		if self.transaction_writes > self.MAX_WRITES_PER_TRANSACTION:
			if self.auto_commit_on_many_writes:
				self.commit()
			else:
				msg = "<br><br>" + _("Too many changes to database in single action.") + "<br>"
				msg += _("The changes have been reverted.") + "<br>"
				raise frappe.TooManyWritesError(msg)
1 Like