From c132c8e505acd567dac9ae23019b4dc1c763e41c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 10 Apr 2019 10:39:54 +0100 Subject: [PATCH 1/3] Handle the case of `get_missing_events` failing Currently if a call to `/get_missing_events` fails we log an exception and stop processing the top level event we received over federation. Instead let's try and handle it sensibly given it is a somewhat expected failure mode. --- synapse/handlers/federation.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 068477888..07a5dc182 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -35,6 +35,7 @@ from synapse.api.errors import ( CodeMessageException, FederationDeniedError, FederationError, + RequestSendFailed, StoreError, SynapseError, ) @@ -493,15 +494,25 @@ class FederationHandler(BaseHandler): # # All that said: Let's try increasing the timout to 60s and see what happens. - missing_events = yield self.federation_client.get_missing_events( - origin, - room_id, - earliest_events_ids=list(latest), - latest_events=[pdu], - limit=10, - min_depth=min_depth, - timeout=60000, - ) + try: + missing_events = yield self.federation_client.get_missing_events( + origin, + room_id, + earliest_events_ids=list(latest), + latest_events=[pdu], + limit=10, + min_depth=min_depth, + timeout=60000, + ) + except RequestSendFailed as e: + # We failed to get the missing events, but since we need to handle + # the case of `get_missing_events` not returning the necessary + # events anyway, it is safe to simply log the error and continue. + logger.warn( + "[%s %s]: Failed to get prev_events for %s: %s", + room_id, event_id, e, + ) + return logger.info( "[%s %s]: Got %d prev_events: %s", From 42e1aa5b2cf34a4c788d23d3376c5f58990a63c9 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 10 Apr 2019 10:43:47 +0100 Subject: [PATCH 2/3] Newsfile --- changelog.d/5042.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5042.bugfix diff --git a/changelog.d/5042.bugfix b/changelog.d/5042.bugfix new file mode 100644 index 000000000..736b07c79 --- /dev/null +++ b/changelog.d/5042.bugfix @@ -0,0 +1 @@ +Fix bug processing incoming events over federation if call to `/get_missing_events` fails. From 2b20d0fb59f78c29e55901754aca2944cbb947b9 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 18 Jun 2019 16:12:53 +0100 Subject: [PATCH 3/3] Fix logline --- synapse/handlers/federation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index cc08e3e02..09af6a41a 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -513,7 +513,7 @@ class FederationHandler(BaseHandler): # the case of `get_missing_events` not returning the necessary # events anyway, it is safe to simply log the error and continue. logger.warn( - "[%s %s]: Failed to get prev_events for %s: %s", + "[%s %s]: Failed to get prev_events: %s", room_id, event_id, e, ) return