Skip to content

Commit

Permalink
Remove Generator from 4 places in PersistEventStore (#17818)
Browse files Browse the repository at this point in the history
Context: matrix-org/synapse#15439
(#15439)

Also see discussion in #17813
  • Loading branch information
realtyem authored Oct 31, 2024
1 parent 7987d5e commit af59a99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.d/17818.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid lost data on some database query retries.
20 changes: 10 additions & 10 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ def _update_current_state_txn(
"""
txn.execute_batch(
sql,
(
[
(
stream_id,
self._instance_name,
Expand All @@ -1699,17 +1699,17 @@ def _update_current_state_txn(
state_key,
)
for etype, state_key in itertools.chain(to_delete, to_insert)
),
],
)
# Now we actually update the current_state_events table

txn.execute_batch(
"DELETE FROM current_state_events"
" WHERE room_id = ? AND type = ? AND state_key = ?",
(
[
(room_id, etype, state_key)
for etype, state_key in itertools.chain(to_delete, to_insert)
),
],
)

# We include the membership in the current state table, hence we do
Expand Down Expand Up @@ -1799,11 +1799,11 @@ def _update_current_state_txn(
txn.execute_batch(
"DELETE FROM local_current_membership"
" WHERE room_id = ? AND user_id = ?",
(
[
(room_id, state_key)
for etype, state_key in itertools.chain(to_delete, to_insert)
if etype == EventTypes.Member and self.is_mine_id(state_key)
),
],
)

if to_insert:
Expand Down Expand Up @@ -3208,26 +3208,26 @@ def _set_push_actions_for_event_and_users_txn(
if notifiable_events:
txn.execute_batch(
sql,
(
[
(
event.room_id,
event.internal_metadata.stream_ordering,
event.depth,
event.event_id,
)
for event in notifiable_events
),
],
)

# Now we delete the staging area for *all* events that were being
# persisted.
txn.execute_batch(
"DELETE FROM event_push_actions_staging WHERE event_id = ?",
(
[
(event.event_id,)
for event, _ in all_events_and_contexts
if event.internal_metadata.is_notifiable()
),
],
)

def _remove_push_actions_for_event_id_txn(
Expand Down

0 comments on commit af59a99

Please sign in to comment.