diff options
author | Erik Johnston <erik@matrix.org> | 2021-08-02 14:37:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-02 13:37:25 +0000 |
commit | 01d45fe964d323e7f66358c2db57d00a44bf2274 (patch) | |
tree | 738e1198533a9f6e9a29df6c5aa42e7c9ee4ee49 /synapse/federation/federation_server.py | |
parent | Allow setting transaction limit for db connections (#10440) (diff) | |
download | synapse-01d45fe964d323e7f66358c2db57d00a44bf2274.tar.xz |
Prune inbound federation queues if they get too long (#10390)
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r-- | synapse/federation/federation_server.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index 2892a11d7d..145b9161d9 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -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 ) |