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

Stop trying to fetch events with event_id=None. #5753

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5753.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop trying to fetch events with event_id=None.
8 changes: 7 additions & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ def create_event(
# tolerate them in event_auth.check().
prev_state_ids = yield context.get_prev_state_ids(self.store)
prev_event_id = prev_state_ids.get((EventTypes.Member, event.sender))
prev_event = yield self.store.get_event(prev_event_id, allow_none=True)
prev_event = (
yield self.store.get_event(prev_event_id, allow_none=True)
if prev_event_id
else None
)
if not prev_event or prev_event.membership != Membership.JOIN:
logger.warning(
(
Expand Down Expand Up @@ -521,6 +525,8 @@ def deduplicate_state_event(self, event, context):
"""
prev_state_ids = yield context.get_prev_state_ids(self.store)
prev_event_id = prev_state_ids.get((event.type, event.state_key))
if not prev_event_id:
return
prev_event = yield self.store.get_event(prev_event_id, allow_none=True)
if not prev_event:
return
Expand Down
5 changes: 4 additions & 1 deletion synapse/storage/events_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ def get_event(
If there is a mismatch, behave as per allow_none.

Returns:
Deferred : A FrozenEvent.
Deferred[EventBase|None]
"""
if not isinstance(event_id, str):
raise TypeError("Invalid event event_id %r" % (event_id,))

events = yield self.get_events_as_list(
[event_id],
check_redacted=check_redacted,
Expand Down
20 changes: 11 additions & 9 deletions synapse/storage/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,18 @@ def _get_next_batch(txn):
avatar_id = current_state_ids.get((EventTypes.RoomAvatar, ""))
canonical_alias_id = current_state_ids.get((EventTypes.CanonicalAlias, ""))

event_ids = [
join_rules_id,
history_visibility_id,
encryption_id,
name_id,
topic_id,
avatar_id,
canonical_alias_id,
]

state_events = yield self.get_events(
[
join_rules_id,
history_visibility_id,
encryption_id,
name_id,
topic_id,
avatar_id,
canonical_alias_id,
]
[ev for ev in event_ids if ev is not None]
)

def _get_or_none(event_id, arg):
Expand Down