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

Clean-up events persistance code #14411

Merged
merged 3 commits into from
Nov 14, 2022
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/14411.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean-up event persistence code.
2 changes: 0 additions & 2 deletions synapse/storage/controllers/persist_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ async def _persist_event_batch(
)
if not is_still_joined:
logger.info("Server no longer in room %s", room_id)
latest_event_ids = set()
current_state = {}
Comment on lines -719 to -720
Copy link
Member Author

Choose a reason for hiding this comment

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

These are both always set higher in this loop and never used after this point in the loop?

delta.no_longer_in_room = True

state_delta_for_room[room_id] = delta
Expand Down
9 changes: 3 additions & 6 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ def _persist_events_txn(
txn: LoggingTransaction,
*,
events_and_contexts: List[Tuple[EventBase, EventContext]],
inhibit_local_membership_updates: bool = False,
state_delta_for_room: Optional[Dict[str, DeltaState]] = None,
new_forward_extremities: Optional[Dict[str, Set[str]]] = None,
inhibit_local_membership_updates: bool,
state_delta_for_room: Dict[str, DeltaState],
new_forward_extremities: Dict[str, Set[str]],
Comment on lines +358 to +360
Copy link
Member Author

Choose a reason for hiding this comment

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

These are always passed (and are never None). _persist_events_txn only has one caller, not sure why this had defaults, etc.

) -> None:
"""Insert some number of room events into the necessary database tables.

Expand All @@ -384,9 +384,6 @@ def _persist_events_txn(
PartialStateConflictError: if attempting to persist a partial state event in
a room that has been un-partial stated.
"""
state_delta_for_room = state_delta_for_room or {}
new_forward_extremities = new_forward_extremities or {}

all_events_and_contexts = events_and_contexts

min_stream_order = events_and_contexts[0][0].internal_metadata.stream_ordering
Expand Down