From a9688ceb7570fd05ada90efe6c2884fb9d7d5245 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 3 May 2021 18:19:27 -0700 Subject: [PATCH] worker: Allow long MissedMessageWorker consumes. This will stop dropping events in the case that the background `maybe_send_batched_email` thread takes longer than 30s. However, see also #15280 and the TODO comment about how we lose events upon restart; this worker is still lossy. --- zerver/worker/queue_processors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index 649b44da0b..3849fc9945 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -561,6 +561,12 @@ class MissedMessageWorker(QueueProcessingWorker): # of the consumer. lock = Lock() + # Because the background `maybe_send_batched_email` thread can + # hold the lock for an indeterminate amount of time, the `consume` + # can block on that for longer than 30s, the default worker + # timeout. Allow arbitrarily-long worker `consume` calls. + MAX_CONSUME_SECONDS = None + def consume(self, event: Dict[str, Any]) -> None: with self.lock: logging.debug("Received missedmessage_emails event: %s", event)