mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-11 22:04:19 -05:00
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: Vasya Boytsov vasiliy.boytsov@phystech.edu
This commit is contained in:
parent
90d9fc7505
commit
e704cc2a48
1
changelog.d/10690.bugfix
Normal file
1
changelog.d/10690.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
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):
|
|||||||
(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
|
||||||
|
# update), then we may as well carry on.
|
||||||
|
if rows:
|
||||||
|
max_depth = max(row[1] for row in rows)
|
||||||
|
|
||||||
if max_depth < token.topological:
|
if max_depth < token.topological:
|
||||||
# We need to ensure we don't delete all the events from the database
|
# 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
|
# otherwise we wouldn't be able to send any events (due to not
|
||||||
# having any backwards extremities)
|
# having any backwards extremities)
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400, "topological_ordering is greater than forward extremeties"
|
400, "topological_ordering is greater than forward extremities"
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("[purge] looking for events to delete")
|
logger.info("[purge] looking for events to delete")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user