From 3a9f5bf6ddb9393b68d8da9f04b2b1162720da7b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 28 Apr 2017 11:26:46 +0100 Subject: Don't fetch state for missing events that we fetched --- synapse/handlers/federation.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'synapse/handlers/federation.py') diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index ebbf844489..33321699a6 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -171,6 +171,12 @@ class FederationHandler(BaseHandler): yield self._get_missing_events_for_pdu( origin, pdu, prevs, min_depth ) + + # Update the set of things we've seen after trying to + # fetch the missing stuff + have_seen = yield self.store.have_events( + [ev for ev, _ in pdu.prev_events] + ) elif prevs - seen: logger.info( "Not fetching %d missing events for room %r,event %s: %r...", -- cgit 1.4.1 From 9b147cd73049c6222fa6c3b45dfb2a360de93cc4 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 28 Apr 2017 11:55:25 +0100 Subject: Remove unncessary call in _get_missing_events_for_pdu --- synapse/handlers/federation.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'synapse/handlers/federation.py') diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 33321699a6..43d1ec859d 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -177,6 +177,17 @@ class FederationHandler(BaseHandler): have_seen = yield self.store.have_events( [ev for ev, _ in pdu.prev_events] ) + + seen = set(have_seen.keys()) + if prevs - seen: + logger.info( + "Still missing %d prev events for %s: %r...", + len(prevs - seen), pdu.event_id, list(prevs - seen)[:5] + ) + else: + logger.info( + "Found all missing prev events for %s", pdu.event_id + ) elif prevs - seen: logger.info( "Not fetching %d missing events for room %r,event %s: %r...", @@ -294,19 +305,6 @@ class FederationHandler(BaseHandler): get_missing=False ) - have_seen = yield self.store.have_events( - [ev for ev, _ in pdu.prev_events] - ) - seen = set(have_seen.keys()) - if prevs - seen: - logger.info( - "Still missing %d prev events for %s: %r...", - len(prevs - seen), pdu.event_id, list(prevs - seen)[:5] - ) - else: - logger.info("Found all missing prev events for %s", pdu.event_id) - defer.returnValue(have_seen) - @log_function @defer.inlineCallbacks def _process_received_pdu(self, origin, pdu, state, auth_chain): -- cgit 1.4.1 From 2347efc065912a0dca6fd0611012b853d62e6629 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 28 Apr 2017 12:46:53 +0100 Subject: Fixup --- synapse/handlers/federation.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'synapse/handlers/federation.py') diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 43d1ec859d..be2ea0cd56 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -174,11 +174,9 @@ class FederationHandler(BaseHandler): # Update the set of things we've seen after trying to # fetch the missing stuff - have_seen = yield self.store.have_events( - [ev for ev, _ in pdu.prev_events] - ) + have_seen = yield self.store.have_events(prevs) - seen = set(have_seen.keys()) + seen = set(have_seen.iterkeys()) if prevs - seen: logger.info( "Still missing %d prev events for %s: %r...", @@ -231,19 +229,15 @@ class FederationHandler(BaseHandler): Args: origin (str): Origin of the pdu. Will be called to get the missing events pdu: received pdu - prevs (str[]): List of event ids which we are missing + prevs (set(str)): List of event ids which we are missing min_depth (int): Minimum depth of events to return. - - Returns: - Deferred: updated have_seen dictionary """ # We recalculate seen, since it may have changed. have_seen = yield self.store.have_events(prevs) seen = set(have_seen.keys()) if not prevs - seen: - # nothing left to do - defer.returnValue(have_seen) + return latest = yield self.store.get_latest_event_ids_in_room( pdu.room_id -- cgit 1.4.1 From ef862186dd6b04210a536cbe3126e018260f8467 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 3 May 2017 10:06:43 +0100 Subject: Merge together redundant calculations/logging --- synapse/handlers/federation.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'synapse/handlers/federation.py') diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index be2ea0cd56..2af9849ed0 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -175,14 +175,9 @@ class FederationHandler(BaseHandler): # Update the set of things we've seen after trying to # fetch the missing stuff have_seen = yield self.store.have_events(prevs) - seen = set(have_seen.iterkeys()) - if prevs - seen: - logger.info( - "Still missing %d prev events for %s: %r...", - len(prevs - seen), pdu.event_id, list(prevs - seen)[:5] - ) - else: + + if not prevs - seen: logger.info( "Found all missing prev events for %s", pdu.event_id ) @@ -193,8 +188,6 @@ class FederationHandler(BaseHandler): list(prevs - seen)[:5], ) - prevs = {e_id for e_id, _ in pdu.prev_events} - seen = set(have_seen.keys()) if prevs - seen: logger.info( "Still missing %d events for room %r: %r...", -- cgit 1.4.1