MariaDB slave setup is causing error while exporting csv with Report Builder


Setup read operations from slave/secondary mysql system is enabled and everything working fine except: when I’m trying to export something, i.e: Sales Invoice list using the Report Builder feature, throwing this error.

Whereas, other default reports, i.e Sales Register, exporting them is working just fine. Can anyone please point out what went wrong?

Thanks in advance.

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 65, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 31, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 67, in execute_cmd
    return, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 1177, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 614, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/", line 289, in export_query
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/access_log/", line 35, in make_access_log
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 233, in insert
    self.set_new_name(set_name=set_name, set_child_names=set_child_names)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 423, in set_new_name
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 61, in set_new_name
    set_name_from_naming_options(autoname, doc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 96, in set_name_from_naming_options = _format_autoname(autoname, doc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 353, in _format_autoname
    name = re.sub(r"(\{[\w | #]+\})", get_param_value_for_match, autoname_value)
  File "/usr/local/lib/python3.7/", line 194, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 350, in get_param_value_for_match
    return parse_naming_series([trimmed_param], doc=doc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 170, in parse_naming_series
    part = getseries(n, digits)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 200, in getseries
    current = frappe.db.sql("SELECT `current` FROM `tabSeries` WHERE `name`=%s FOR UPDATE", (key,))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/", line 147, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 148, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 310, in _query
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 775, in _read_query_result
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 1156, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 725, in _read_packet
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 221, in raise_for_error
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1290, 'The MariaDB server is running with the --read-only option so it cannot execute this statement')

The error indicates that ERPNext couldn’t start a transaction within the slave.

How did you setup Master/Slave ? In the database level or app level (config) ?

The setup is a docker_swarm based setup following this frappe-docker-swarm

and then on the site_config.json setup this. Perhaps @revant_one could tell more about the mechanism of master-slave setup.

GitHub - bitnami/bitnami-docker-mariadb: Bitnami Docker Image for MariaDB this is where the replication setup is taken from

1 Like

Exporting a CSV file is triggering the creation of an Access Log. Since the db connected to the transaction is a read only one, the action fails.

This seems to be a bug in Frappe.

Edit: Raised a possible fix


@gavindsouza Hi,

The PR !14142 fixed the issue. Apparently I found a new one. Seems like it also causes issue while generating Trial Balance Report

@gavindsouza & @revant_one hi, could you test this new point that Trial balance report isn’t working?

@gavindsouza, hi, the issue with Trial Balance report generation, is it solved? can we create another issue on github?