diff options
author | Erik Johnston <erik@matrix.org> | 2019-02-20 16:54:35 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-02-20 18:14:12 +0000 |
commit | 71b625d80806886794c5e72f7ff11432e99b736c (patch) | |
tree | 3150c6d7a279d464f32529669494afdccb10feee /synapse/handlers/federation.py | |
parent | Merge pull request #4694 from matrix-org/erikj/fix_sentry_config_format (diff) | |
download | synapse-71b625d80806886794c5e72f7ff11432e99b736c.tar.xz |
Stop backpaginating when events not visible
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r-- | synapse/handlers/federation.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 083f2e0ac3..7b3834a915 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -830,6 +830,37 @@ class FederationHandler(BaseHandler): logger.debug("Not backfilling as no extremeties found.") return + # We only want to paginate if we can actually see the events we'll get, + # as otherwise we'll just spend a lot of resources to get redacted + # events. + # + # We do this by filtering all the extremities and seeing if any remain. + # Given we don't have the extremity events themselves, we need to + # actually check the events that references them. + # + # TODO: Filter the list of extremities if we do do a backfill + # TODO: Correctly handle the case where we are allowed to see the + # forward event but not the extremity, e.g. in the case of initial + # join of the server. + + forward_events = yield self.store.get_forward_events( + list(extremities), + ) + + extremities_events = yield self.store.get_events( + forward_events, + check_redacted=False, + get_prev_content=False, + ) + + filtered_extremities = yield filter_events_for_server( + self.store, self.server_name, list(extremities_events.values()), + redact=False, + ) + + if not filtered_extremities: + defer.returnValue(False) + # Check if we reached a point where we should start backfilling. sorted_extremeties_tuple = sorted( extremities.items(), |