mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 15:11:52 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user