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

Keep track when we try and fail to process a pulled event #13589

Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e0d7fab
Keep track when we tried to backfill an event
MadLittleMods Aug 23, 2022
b8d55d3
Record in some fail spots
MadLittleMods Aug 25, 2022
f63d823
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Aug 25, 2022
bec26e2
Record and clear attempts
MadLittleMods Aug 25, 2022
fee37c3
Add changelog
MadLittleMods Aug 25, 2022
d1290be
Remove from when spam checker fails
MadLittleMods Aug 25, 2022
f9119d0
Custom upsert to increment
MadLittleMods Aug 25, 2022
f5c6fe7
Fix lints
MadLittleMods Aug 25, 2022
16ebec0
Remove extra whitespace
MadLittleMods Aug 25, 2022
ce07aa1
Move to correct folder
MadLittleMods Aug 25, 2022
5811ba1
Set the version back
MadLittleMods Aug 25, 2022
cf2b093
Fix `TypeError: not all arguments converted during string formatting`
MadLittleMods Aug 25, 2022
cbb4194
Add test to make sure failed backfill attempts are recorded
MadLittleMods Aug 26, 2022
621c5d3
Clean up test
MadLittleMods Aug 26, 2022
75c07bb
Fix comments
MadLittleMods Aug 26, 2022
783cce5
Add test for clearing backfill attempts
MadLittleMods Aug 26, 2022
54ef84b
Maybe a better comment
MadLittleMods Aug 26, 2022
e4192d7
Update table name with "failed" and include room_id in the primary key
MadLittleMods Aug 31, 2022
7a44932
Rename to record_event_failed_backfill_attempt
MadLittleMods Aug 31, 2022
86d98ca
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Aug 31, 2022
1464101
Add _unsafe_to_upsert_tables check
MadLittleMods Sep 1, 2022
71c7738
Add foreign key references
MadLittleMods Sep 1, 2022
df8c76d
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Sep 1, 2022
d45b078
Remove reference to event that won't be in the events table
MadLittleMods Sep 1, 2022
33ad64e
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Sep 9, 2022
63bec99
Remove emulated upsert code (all of our dbs no support it)
MadLittleMods Sep 9, 2022
31d7502
Table rename `event_failed_pull_attempts`
MadLittleMods Sep 9, 2022
0b5f1db
Add `last_cause` column
MadLittleMods Sep 9, 2022
4ce7709
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Sep 12, 2022
d3a1f84
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Sep 13, 2022
1347686
Update schema version summary
MadLittleMods Sep 13, 2022
57182dc
Remove backfilled check since we plan to go general anyway
MadLittleMods Sep 14, 2022
e58bc65
Merge branch 'develop' into madlittlemods/keep-track-when-we-tried-to…
MadLittleMods Sep 14, 2022
70019d2
Move change to latest delta 73
MadLittleMods Sep 14, 2022
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
66 changes: 8 additions & 58 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,27 +1309,15 @@ async def record_event_failed_backfill_attempt(
room_id: The room where the event failed to backfill from
event_id: The event that failed to be backfilled
"""
if (
self.database_engine.can_native_upsert
and "event_failed_backfill_attempts"
not in self.db_pool._unsafe_to_upsert_tables
):
await self.db_pool.runInteraction(
"record_event_failed_backfill_attempt",
self._record_event_failed_backfill_attempt_upsert_native_txn,
room_id,
event_id,
db_autocommit=True, # Safe as its a single upsert
)
else:
await self.db_pool.runInteraction(
"record_event_failed_backfill_attempt",
self._record_event_failed_backfill_attempt_upsert_emulated_txn,
room_id,
event_id,
)
await self.db_pool.runInteraction(
"record_event_failed_backfill_attempt",
self._record_event_failed_backfill_attempt_upsert_txn,
room_id,
event_id,
db_autocommit=True, # Safe as it's a single upsert
)
MadLittleMods marked this conversation as resolved.
Show resolved Hide resolved

def _record_event_failed_backfill_attempt_upsert_native_txn(
def _record_event_failed_backfill_attempt_upsert_txn(
self,
txn: LoggingTransaction,
room_id: str,
Expand All @@ -1349,44 +1337,6 @@ def _record_event_failed_backfill_attempt_upsert_native_txn(

txn.execute(sql, (room_id, event_id, 1, self._clock.time_msec()))

def _record_event_failed_backfill_attempt_upsert_emulated_txn(
self,
txn: LoggingTransaction,
room_id: str,
event_id: str,
) -> None:
self.database_engine.lock_table(txn, "event_failed_backfill_attempts")

prev_row = self.db_pool.simple_select_one_txn(
txn,
table="event_failed_backfill_attempts",
keyvalues={"room_id": room_id, "event_id": event_id},
retcols=("num_attempts"),
allow_none=True,
)

if not prev_row:
self.db_pool.simple_insert_txn(
txn,
table="event_failed_backfill_attempts",
values={
"room_id": room_id,
"event_id": event_id,
"num_attempts": 1,
"last_attempt_ts": self._clock.time_msec(),
},
)
else:
self.db_pool.simple_update_one_txn(
txn,
table="event_failed_backfill_attempts",
keyvalues={"room_id": room_id, "event_id": event_id},
updatevalues={
"num_attempts": prev_row["num_attempts"] + 1,
"last_attempt_ts": self._clock.time_msec(),
},
)

async def get_missing_events(
self,
room_id: str,
Expand Down