fix(accounts): savepoint subscription-status update loop in Payment Entry (Postgres)

trigger_invoice_update_for_subscriptions loops invoices calling refresh_subscription_status (db_set/save); on failure the except calls frappe.log_error with no rollback, raising InFailedSqlTransaction on Postgres, and the next invoice runs in the poisoned txn. Savepoint per iteration + rollback(save_point=) before log_error. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:48:26 +05:30
parent f3785f10a2
commit 944eeb5921

View File

@@ -514,10 +514,12 @@ class PaymentEntry(AccountsController):
invoice_names.add((ref.reference_doctype, ref.reference_name))
for doctype, name in invoice_names:
frappe.db.savepoint("subscription_update")
try:
doc = frappe.get_doc(doctype, name)
doc.refresh_subscription_status()
except Exception:
frappe.db.rollback(save_point="subscription_update")
frappe.log_error(_("Failed to update subscription status for {0} {1}").format(doctype, name))
def set_missing_values(self):