Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
missedmessage_emails: Skip locked rows when finding events.
Alex Vandivere3405867ac51
diff --git a/zerver/worker/missedmessage_emails.py b/zerver/worker/missedmessage_emails.pyindex 7ec99c982f3..1e0e01d3473 100644--- a/zerver/worker/missedmessage_emails.py+++ b/zerver/worker/missedmessage_emails.py@@ -228,7 +228,15 @@ class MissedMessageWorker(QueueProcessingWorker):with transaction.atomic(durable=True):events_to_process = ScheduledMessageNotificationEmail.objects.filter(scheduled_timestamp__lte=current_time- ).select_for_update()+ ).select_for_update(+ # We intend to delete these rows later, so we need a+ # FOR UPDATE lock.+ no_key=False,+ # If another worker (or message deletion) has locked+ # one of the rows, we can look at it later (if it+ # still exists). This avoids deadlocks.+ skip_locked=True,+ )# Batch the entries by userevents_by_recipient: dict[int, dict[int, MissedMessageData]] = defaultdict(dict)