mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-09 11:32:01 +01:00
Merge pull request #1012 from matrix-org/erikj/limit_backfill_uri
Limit number of extremeties in backfill request
This commit is contained in:
commit
7c6f4f9427
1 changed files with 5 additions and 4 deletions
|
@ -274,7 +274,7 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
@log_function
|
@log_function
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def backfill(self, dest, room_id, limit, extremities=[]):
|
def backfill(self, dest, room_id, limit, extremities):
|
||||||
""" Trigger a backfill request to `dest` for the given `room_id`
|
""" Trigger a backfill request to `dest` for the given `room_id`
|
||||||
|
|
||||||
This will attempt to get more events from the remote. This may return
|
This will attempt to get more events from the remote. This may return
|
||||||
|
@ -284,9 +284,6 @@ class FederationHandler(BaseHandler):
|
||||||
if dest == self.server_name:
|
if dest == self.server_name:
|
||||||
raise SynapseError(400, "Can't backfill from self.")
|
raise SynapseError(400, "Can't backfill from self.")
|
||||||
|
|
||||||
if not extremities:
|
|
||||||
extremities = yield self.store.get_oldest_events_in_room(room_id)
|
|
||||||
|
|
||||||
events = yield self.replication_layer.backfill(
|
events = yield self.replication_layer.backfill(
|
||||||
dest,
|
dest,
|
||||||
room_id,
|
room_id,
|
||||||
|
@ -455,6 +452,10 @@ class FederationHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
max_depth = sorted_extremeties_tuple[0][1]
|
max_depth = sorted_extremeties_tuple[0][1]
|
||||||
|
|
||||||
|
# We don't want to specify too many extremities as it causes the backfill
|
||||||
|
# request URI to be too long.
|
||||||
|
extremities = dict(sorted_extremeties_tuple[:5])
|
||||||
|
|
||||||
if current_depth > max_depth:
|
if current_depth > max_depth:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Not backfilling as we don't need to. %d < %d",
|
"Not backfilling as we don't need to. %d < %d",
|
||||||
|
|
Loading…
Reference in a new issue