Remove `Generator` from 4 places in `PersistEventStore` (#17818)
Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
This commit is contained in:
parent
7987d5e638
commit
af59a99933
|
@ -0,0 +1 @@
|
||||||
|
Avoid lost data on some database query retries.
|
|
@ -1686,7 +1686,7 @@ class PersistEventsStore:
|
||||||
"""
|
"""
|
||||||
txn.execute_batch(
|
txn.execute_batch(
|
||||||
sql,
|
sql,
|
||||||
(
|
[
|
||||||
(
|
(
|
||||||
stream_id,
|
stream_id,
|
||||||
self._instance_name,
|
self._instance_name,
|
||||||
|
@ -1699,17 +1699,17 @@ class PersistEventsStore:
|
||||||
state_key,
|
state_key,
|
||||||
)
|
)
|
||||||
for etype, state_key in itertools.chain(to_delete, to_insert)
|
for etype, state_key in itertools.chain(to_delete, to_insert)
|
||||||
),
|
],
|
||||||
)
|
)
|
||||||
# Now we actually update the current_state_events table
|
# Now we actually update the current_state_events table
|
||||||
|
|
||||||
txn.execute_batch(
|
txn.execute_batch(
|
||||||
"DELETE FROM current_state_events"
|
"DELETE FROM current_state_events"
|
||||||
" WHERE room_id = ? AND type = ? AND state_key = ?",
|
" WHERE room_id = ? AND type = ? AND state_key = ?",
|
||||||
(
|
[
|
||||||
(room_id, etype, state_key)
|
(room_id, etype, state_key)
|
||||||
for etype, state_key in itertools.chain(to_delete, to_insert)
|
for etype, state_key in itertools.chain(to_delete, to_insert)
|
||||||
),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# We include the membership in the current state table, hence we do
|
# We include the membership in the current state table, hence we do
|
||||||
|
@ -1799,11 +1799,11 @@ class PersistEventsStore:
|
||||||
txn.execute_batch(
|
txn.execute_batch(
|
||||||
"DELETE FROM local_current_membership"
|
"DELETE FROM local_current_membership"
|
||||||
" WHERE room_id = ? AND user_id = ?",
|
" WHERE room_id = ? AND user_id = ?",
|
||||||
(
|
[
|
||||||
(room_id, state_key)
|
(room_id, state_key)
|
||||||
for etype, state_key in itertools.chain(to_delete, to_insert)
|
for etype, state_key in itertools.chain(to_delete, to_insert)
|
||||||
if etype == EventTypes.Member and self.is_mine_id(state_key)
|
if etype == EventTypes.Member and self.is_mine_id(state_key)
|
||||||
),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
if to_insert:
|
if to_insert:
|
||||||
|
@ -3208,7 +3208,7 @@ class PersistEventsStore:
|
||||||
if notifiable_events:
|
if notifiable_events:
|
||||||
txn.execute_batch(
|
txn.execute_batch(
|
||||||
sql,
|
sql,
|
||||||
(
|
[
|
||||||
(
|
(
|
||||||
event.room_id,
|
event.room_id,
|
||||||
event.internal_metadata.stream_ordering,
|
event.internal_metadata.stream_ordering,
|
||||||
|
@ -3216,18 +3216,18 @@ class PersistEventsStore:
|
||||||
event.event_id,
|
event.event_id,
|
||||||
)
|
)
|
||||||
for event in notifiable_events
|
for event in notifiable_events
|
||||||
),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Now we delete the staging area for *all* events that were being
|
# Now we delete the staging area for *all* events that were being
|
||||||
# persisted.
|
# persisted.
|
||||||
txn.execute_batch(
|
txn.execute_batch(
|
||||||
"DELETE FROM event_push_actions_staging WHERE event_id = ?",
|
"DELETE FROM event_push_actions_staging WHERE event_id = ?",
|
||||||
(
|
[
|
||||||
(event.event_id,)
|
(event.event_id,)
|
||||||
for event, _ in all_events_and_contexts
|
for event, _ in all_events_and_contexts
|
||||||
if event.internal_metadata.is_notifiable()
|
if event.internal_metadata.is_notifiable()
|
||||||
),
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def _remove_push_actions_for_event_id_txn(
|
def _remove_push_actions_for_event_id_txn(
|
||||||
|
|
Loading…
Reference in New Issue