fix: improve email queue reliability (#23070)

* feat: control email queue batch size with config

* fix: Give emails who failed once less priority while sending
This commit is contained in:
Ankush Menat 2023-11-03 15:10:37 +05:30 committed by GitHub
parent ff14c52059
commit be2beeed9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,8 +151,10 @@ def flush(from_test=False):
def get_queue():
batch_size = cint(frappe.conf.email_queue_batch_size) or 500
return frappe.db.sql(
"""select
f"""select
name, sender
from
`tabEmail Queue`
@ -160,8 +162,8 @@ def get_queue():
(status='Not Sent' or status='Partially Sent') and
(send_after is null or send_after < %(now)s)
order
by priority desc, creation asc
limit 500""",
by priority desc, retry asc, creation asc
limit {batch_size}""",
{"now": now_datetime()},
as_dict=True,
)