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?