fix(crm): savepoint Email Campaign send loop (Postgres)

send_mail (called per campaign schedule in a loop) inserts a Communication via make(); on failure the except calls frappe.log_error with no rollback, raising InFailedSqlTransaction on Postgres and poisoning subsequent sends. Savepoint before make() + rollback(save_point=) before log_error. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:48:28 +05:30
parent 4feb9f9910
commit f41e8208d8

View File

@@ -174,6 +174,7 @@ def send_mail(entry, email_campaign):
subject = frappe.render_template(email_template.get("subject"), context)
content = frappe.render_template(email_template.response_, context)
frappe.db.savepoint("email_campaign_send")
try:
comm = make(
doctype="Email Campaign",
@@ -197,6 +198,7 @@ def send_mail(entry, email_campaign):
queue_separately=True,
)
except Exception:
frappe.db.rollback(save_point="email_campaign_send")
frappe.log_error(title="Email Campaign Failed.")
return comm