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

Use StateResolutionHandler to resolve state in persist_events #2864

Merged
merged 5 commits into from
Feb 13, 2018
Merged
Changes from 1 commit
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
13 changes: 9 additions & 4 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,16 +515,21 @@ def _get_new_state_after_events(self, events_context, new_latest_event_ids):
if ctx.current_state_ids is None:
raise Exception("Unknown current state")

if ctx.state_group is None:
# I don't think this can happen, but let's double-check
raise Exception(
"Context for new extremity event %s has no state "
"group" % event_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I do prefer always using tuples rather than relying on strings working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in you'd prefer (event_id, ) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally yes, (or (event_id,) without the space), as its very confusing if there is a bug and event_id suddenly becomes iterable and then the logging explodes. In this particular case its probably fine though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair

)

# If we've already seen the state group don't bother adding
# it to the state sets again
if ctx.state_group not in state_groups:
state_sets.append(ctx.current_state_ids)
if ctx.delta_ids or hasattr(ev, "state_key"):
was_updated = True
if ctx.state_group:
# Add this as a seen state group (if it has a state
# group)
state_groups.add(ctx.state_group)
# Add this as a seen state group
state_groups.add(ctx.state_group)
break
else:
# If we couldn't find it, then we'll need to pull
Expand Down