From 944eeb5921ff8477c5d7656b75b26513cf2c311f Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 22:48:26 +0530 Subject: [PATCH] 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. --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 3b6cb7920b9..b4005436ec0 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -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):