Skip to content
Snippets Groups Projects
Unverified Commit e704cc2a authored by Kokokokoka's avatar Kokokokoka Committed by GitHub
Browse files

In `_purge_history_txn`, ensure that txn.fetchall has elements before accessing rows (#10690)


This change adds a check for row existence before accessing row element, this should fix issue #10669
Signed-off-by: default avatarVasya Boytsov <vasiliy.boytsov@phystech.edu>
parent 90d9fc75
No related branches found
No related tags found
No related merge requests found
Fix a long-standing bug that caused an `AssertionError` when purging history in certain rooms. Contributed by @Kokokokoka.
...@@ -102,15 +102,19 @@ class PurgeEventsStore(StateGroupWorkerStore, CacheInvalidationWorkerStore): ...@@ -102,15 +102,19 @@ class PurgeEventsStore(StateGroupWorkerStore, CacheInvalidationWorkerStore):
(room_id,), (room_id,),
) )
rows = txn.fetchall() rows = txn.fetchall()
max_depth = max(row[1] for row in rows) # if we already have no forwards extremities (for example because they were
# cleared out by the `delete_old_current_state_events` background database
if max_depth < token.topological: # update), then we may as well carry on.
# We need to ensure we don't delete all the events from the database if rows:
# otherwise we wouldn't be able to send any events (due to not max_depth = max(row[1] for row in rows)
# having any backwards extremities)
raise SynapseError( if max_depth < token.topological:
400, "topological_ordering is greater than forward extremeties" # We need to ensure we don't delete all the events from the database
) # otherwise we wouldn't be able to send any events (due to not
# having any backwards extremities)
raise SynapseError(
400, "topological_ordering is greater than forward extremities"
)
logger.info("[purge] looking for events to delete") logger.info("[purge] looking for events to delete")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment