Prune inbound federation queues if they get too long (#10390)

This commit is contained in:
Erik Johnston 2021-08-02 14:37:25 +01:00 committed by GitHub
parent ba5287f5e8
commit 01d45fe964
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 177 additions and 2 deletions

View file

@ -1024,6 +1024,23 @@ class FederationServer(FederationBase):
origin, event = next
# Prune the event queue if it's getting large.
#
# We do this *after* handling the first event as the common case is
# that the queue is empty (/has the single event in), and so there's
# no need to do this check.
pruned = await self.store.prune_staged_events_in_room(room_id, room_version)
if pruned:
# If we have pruned the queue check we need to refetch the next
# event to handle.
next = await self.store.get_next_staged_event_for_room(
room_id, room_version
)
if not next:
break
origin, event = next
lock = await self.store.try_acquire_lock(
_INBOUND_EVENT_HANDLING_LOCK_NAME, room_id
)