fix: dont fail repost for recoverable errors (backport #30979) (#31023)

recoverable erros:
1. timeout
2. lock/deadlocks

(cherry picked from commit 80d959c579)

Co-authored-by: Ankush Menat <me@ankush.dev>
This commit is contained in:
mergify[bot]
2022-05-16 12:08:32 +05:30
committed by GitHub
parent 6adeaa1de6
commit a019cb6caa
3 changed files with 30 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
import frappe
def execute():
recoverable = ("QueryDeadlockError", "QueryTimeoutError", "JobTimeoutException")
failed_reposts = frappe.get_all(
"Repost Item Valuation",
fields=["name", "error_log"],
filters={
"status": "Failed",
"docstatus": 1,
"modified": (">", "2022-04-20"),
"error_log": ("is", "set"),
},
)
for riv in failed_reposts:
for exc in recoverable:
if exc in riv.error_log:
frappe.db.set_value("Repost Item Valuation", riv.name, "status", "Queued")
break