summary refs log tree commit diff
path: root/synapse/push/emailpusher.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-04-02 16:45:33 +0100
committerErik Johnston <erik@matrix.org>2019-04-02 16:59:13 +0100
commit5bec8d660d4b7d940336048c2ce937225840b5f4 (patch)
treeab7d1c156e0995658ac0e52e0078337638c87094 /synapse/push/emailpusher.py
parentFix sync bug when accepting invites (#4956) (diff)
downloadsynapse-5bec8d660d4b7d940336048c2ce937225840b5f4.tar.xz
Make starting pushers faster during start up
We start all pushers on start up and immediately start a background
process to fetch push to send. This makes start up incredibly painful
when dealing with many pushers.

Instead, let's do a quick fast DB check to see if there *may* be push to
send and only start the background processes for those pushers. We also
stagger starting up and doing those checks so that we don't try and
handle all pushers at once.
Diffstat (limited to 'synapse/push/emailpusher.py')
-rw-r--r--synapse/push/emailpusher.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/push/emailpusher.py b/synapse/push/emailpusher.py
index 50e1007d84..e8ee67401f 100644
--- a/synapse/push/emailpusher.py
+++ b/synapse/push/emailpusher.py
@@ -72,8 +72,15 @@ class EmailPusher(object):
 
         self._is_processing = False
 
-    def on_started(self):
-        if self.mailer is not None:
+    def on_started(self, should_check_for_notifs):
+        """Called when this pusher has been started.
+
+        Args:
+            should_check_for_notifs (bool): Whether we should immediately
+                check for push to send. Set to False only if it's known there
+                is nothing to send
+        """
+        if should_check_for_notifs and self.mailer is not None:
             self._start_processing()
 
     def on_stop(self):