Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix breaking event sending due to bad push rule (#13547)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erikjohnston authored Aug 17, 2022
1 parent ba8938b commit 436e0eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/13547.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of sending messages in rooms with thousands of local users.
13 changes: 12 additions & 1 deletion synapse/push/baserules.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@
"""

import itertools
import logging
from typing import Dict, Iterator, List, Mapping, Sequence, Tuple, Union

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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 436e0eb

Please sign in to comment.