Repost Item Valuation got stuck & failed

Hello everyone,

I’m using ERPNext for many years and got no major issues, just recently from March 2025, I start noticing my Profit & Loss report got issue on G/L Cost of Goods Sold, and after investigation and looking into forum, the main culprit is because of Repost Item Valuation, and for my case, I have gone through the forum and followed all the recommendation & solutions as following:

  1. Go to each item in Repost Item Valuation and click “Start Reposting”
  2. Check RQ Jobs & ensure Scheduler is “Active”
  3. Bench Update, Bench Migrate & Bench Restart

After followed all these solutions, I’m still facing the issue, and what I’m facing issue is RQ Job “erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.repost_entries” keep started & failed, with below exception:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/rq/worker.py", line 1428, in perform_job
    rv = job.perform()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 1278, in perform
    self._result = self._execute()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/rq/job.py", line 1315, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 253, in execute_job
    frappe.db.commit()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 1175, in commit
    self.sql("commit")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 230, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 562, in query
    self._execute_command(COMMAND.COM_QUERY, sql)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 843, in _execute_command
    raise err.InterfaceError(0, "")
pymysql.err.InterfaceError: (0, '')

What is the root cause of the problem and what is the solution for this issue?



The way to fix this:

  1. Go to the error log and filter for “Repost Item Valuation”; the issue is likely due to a Lock Wait timeout in MySQL.

  2. By default, MariaDB’s innodb_lock_wait_timeout is set to only 50 seconds.

    Add or update this in /etc/mysql/mariadb.conf.d/50-server.cnf (or /etc/my.cnf):

    [mysqld]
    # Increase InnoDB lock wait time from 50 seconds to 10-15 minutes
    innodb_lock_wait_timeout = 900
    

3. Restart your DB.

4. Also, the repost job is 25 mins default timeout, and runs every hour. This is not enough time if you have such a massive backlog, you can temporarily disable (make stopped enabled) the hourly job in the Scheduled Job Type doctype, and then manually start the job like this:

bench --site $SITE console
frappe.enqueue(  method="erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.repost_entries",
    queue="long",
    timeout=18000,   # 5 hours timeout for example
    now=False 
)

You can then re-enable the Job in the Scheduled Job Type

1 Like