summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-08-17 12:02:38 +0100
committerGitHub <noreply@github.com>2022-08-17 11:02:38 +0000
commit436e0eb39a50c0d83b8573ae92ee84f87f21fbd3 (patch)
tree0aaa9c58b0b7947085f262f72263dc9edfcece96
parentReject non-strict types in Pydantic models (#13502) (diff)
downloadsynapse-436e0eb39a50c0d83b8573ae92ee84f87f21fbd3.tar.xz
Fix breaking event sending due to bad push rule (#13547)
Broke by #13522

It looks like we have some rules in the DB with a priority class less
than 0 that don't override the base rules. Before these were just
dropped, but #13522 made that a hard error.
-rw-r--r--changelog.d/13547.misc1
-rw-r--r--synapse/push/baserules.py13
2 files changed, 13 insertions, 1 deletions
diff --git a/changelog.d/13547.misc b/changelog.d/13547.misc
new file mode 100644
index 0000000000..0a8827205d
--- /dev/null
+++ b/changelog.d/13547.misc
@@ -0,0 +1 @@
+Improve performance of sending messages in rooms with thousands of local users.
diff --git a/synapse/push/baserules.py b/synapse/push/baserules.py
index c3e072033c..440205e80c 100644
--- a/synapse/push/baserules.py
+++ b/synapse/push/baserules.py
@@ -49,6 +49,7 @@ kind, etc, etc.
 """
 
 import itertools
+import logging
 from typing import Dict, Iterator, List, Mapping, Sequence, Tuple, Union
 
 import attr
@@ -56,6 +57,8 @@ import attr
 from synapse.config.experimental import ExperimentalConfig
 from synapse.push.rulekinds import PRIORITY_CLASS_MAP
 
+logger = logging.getLogger(__name__)
+
 
 @attr.s(auto_attribs=True, slots=True, frozen=True)
 class PushRule:
@@ -199,8 +202,16 @@ def compile_push_rules(rawrules: List[PushRule]) -> PushRules:
             collection = rules.sender
         elif rule.priority_class == 1:
             collection = rules.underride
+        elif rule.priority_class <= 0:
+            logger.info(
+                "Got rule with priority class less than zero, but doesn't override a base rule: %s",
+                rule,
+            )
+            continue
         else:
-            raise Exception(f"Unknown priority class: {rule.priority_class}")
+            # We log and continue here so as not to break event sending
+            logger.error("Unknown priority class: %", rule.priority_class)
+            continue
 
         collection.append(rule)