Fix a number of logged errors caused by remote servers being down. (#10400)
parent
0ae95b3847
commit
7695ca0618
|
@ -0,0 +1 @@
|
||||||
|
Fix a number of logged errors caused by remote servers being down.
|
|
@ -22,6 +22,7 @@ from synapse.api.errors import (
|
||||||
CodeMessageException,
|
CodeMessageException,
|
||||||
Codes,
|
Codes,
|
||||||
NotFoundError,
|
NotFoundError,
|
||||||
|
RequestSendFailed,
|
||||||
ShadowBanError,
|
ShadowBanError,
|
||||||
StoreError,
|
StoreError,
|
||||||
SynapseError,
|
SynapseError,
|
||||||
|
@ -252,12 +253,14 @@ class DirectoryHandler(BaseHandler):
|
||||||
retry_on_dns_fail=False,
|
retry_on_dns_fail=False,
|
||||||
ignore_backoff=True,
|
ignore_backoff=True,
|
||||||
)
|
)
|
||||||
|
except RequestSendFailed:
|
||||||
|
raise SynapseError(502, "Failed to fetch alias")
|
||||||
except CodeMessageException as e:
|
except CodeMessageException as e:
|
||||||
logging.warning("Error retrieving alias")
|
logging.warning("Error retrieving alias")
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
fed_result = None
|
fed_result = None
|
||||||
else:
|
else:
|
||||||
raise
|
raise SynapseError(502, "Failed to fetch alias")
|
||||||
|
|
||||||
if fed_result and "room_id" in fed_result and "servers" in fed_result:
|
if fed_result and "room_id" in fed_result and "servers" in fed_result:
|
||||||
room_id = fed_result["room_id"]
|
room_id = fed_result["room_id"]
|
||||||
|
|
|
@ -1414,12 +1414,15 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
Invites must be signed by the invitee's server before distribution.
|
Invites must be signed by the invitee's server before distribution.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
pdu = await self.federation_client.send_invite(
|
pdu = await self.federation_client.send_invite(
|
||||||
destination=target_host,
|
destination=target_host,
|
||||||
room_id=event.room_id,
|
room_id=event.room_id,
|
||||||
event_id=event.event_id,
|
event_id=event.event_id,
|
||||||
pdu=event,
|
pdu=event,
|
||||||
)
|
)
|
||||||
|
except RequestSendFailed:
|
||||||
|
raise SynapseError(502, f"Can't connect to server {target_host}")
|
||||||
|
|
||||||
return pdu
|
return pdu
|
||||||
|
|
||||||
|
@ -3031,9 +3034,13 @@ class FederationHandler(BaseHandler):
|
||||||
await member_handler.send_membership_event(None, event, context)
|
await member_handler.send_membership_event(None, event, context)
|
||||||
else:
|
else:
|
||||||
destinations = {x.split(":", 1)[-1] for x in (sender_user_id, room_id)}
|
destinations = {x.split(":", 1)[-1] for x in (sender_user_id, room_id)}
|
||||||
|
|
||||||
|
try:
|
||||||
await self.federation_client.forward_third_party_invite(
|
await self.federation_client.forward_third_party_invite(
|
||||||
destinations, room_id, event_dict
|
destinations, room_id, event_dict
|
||||||
)
|
)
|
||||||
|
except (RequestSendFailed, HttpResponseException):
|
||||||
|
raise SynapseError(502, "Failed to forward third party invite")
|
||||||
|
|
||||||
async def on_exchange_third_party_invite_request(
|
async def on_exchange_third_party_invite_request(
|
||||||
self, event_dict: JsonDict
|
self, event_dict: JsonDict
|
||||||
|
|
|
@ -20,7 +20,12 @@ import msgpack
|
||||||
from unpaddedbase64 import decode_base64, encode_base64
|
from unpaddedbase64 import decode_base64, encode_base64
|
||||||
|
|
||||||
from synapse.api.constants import EventTypes, HistoryVisibility, JoinRules
|
from synapse.api.constants import EventTypes, HistoryVisibility, JoinRules
|
||||||
from synapse.api.errors import Codes, HttpResponseException
|
from synapse.api.errors import (
|
||||||
|
Codes,
|
||||||
|
HttpResponseException,
|
||||||
|
RequestSendFailed,
|
||||||
|
SynapseError,
|
||||||
|
)
|
||||||
from synapse.types import JsonDict, ThirdPartyInstanceID
|
from synapse.types import JsonDict, ThirdPartyInstanceID
|
||||||
from synapse.util.caches.descriptors import cached
|
from synapse.util.caches.descriptors import cached
|
||||||
from synapse.util.caches.response_cache import ResponseCache
|
from synapse.util.caches.response_cache import ResponseCache
|
||||||
|
@ -417,6 +422,7 @@ class RoomListHandler(BaseHandler):
|
||||||
repl_layer = self.hs.get_federation_client()
|
repl_layer = self.hs.get_federation_client()
|
||||||
if search_filter:
|
if search_filter:
|
||||||
# We can't cache when asking for search
|
# We can't cache when asking for search
|
||||||
|
try:
|
||||||
return await repl_layer.get_public_rooms(
|
return await repl_layer.get_public_rooms(
|
||||||
server_name,
|
server_name,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
|
@ -425,6 +431,8 @@ class RoomListHandler(BaseHandler):
|
||||||
include_all_networks=include_all_networks,
|
include_all_networks=include_all_networks,
|
||||||
third_party_instance_id=third_party_instance_id,
|
third_party_instance_id=third_party_instance_id,
|
||||||
)
|
)
|
||||||
|
except (RequestSendFailed, HttpResponseException):
|
||||||
|
raise SynapseError(502, "Failed to fetch room list")
|
||||||
|
|
||||||
key = (
|
key = (
|
||||||
server_name,
|
server_name,
|
||||||
|
|
|
@ -43,6 +43,7 @@ from twisted.internet import defer
|
||||||
from twisted.internet.error import DNSLookupError
|
from twisted.internet.error import DNSLookupError
|
||||||
from twisted.internet.interfaces import IReactorTime
|
from twisted.internet.interfaces import IReactorTime
|
||||||
from twisted.internet.task import _EPSILON, Cooperator
|
from twisted.internet.task import _EPSILON, Cooperator
|
||||||
|
from twisted.web.client import ResponseFailed
|
||||||
from twisted.web.http_headers import Headers
|
from twisted.web.http_headers import Headers
|
||||||
from twisted.web.iweb import IBodyProducer, IResponse
|
from twisted.web.iweb import IBodyProducer, IResponse
|
||||||
|
|
||||||
|
@ -262,6 +263,15 @@ async def _handle_response(
|
||||||
request.uri.decode("ascii"),
|
request.uri.decode("ascii"),
|
||||||
)
|
)
|
||||||
raise RequestSendFailed(e, can_retry=True) from e
|
raise RequestSendFailed(e, can_retry=True) from e
|
||||||
|
except ResponseFailed as e:
|
||||||
|
logger.warning(
|
||||||
|
"{%s} [%s] Failed to read response - %s %s",
|
||||||
|
request.txn_id,
|
||||||
|
request.destination,
|
||||||
|
request.method,
|
||||||
|
request.uri.decode("ascii"),
|
||||||
|
)
|
||||||
|
raise RequestSendFailed(e, can_retry=True) from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"{%s} [%s] Error reading response %s %s: %s",
|
"{%s} [%s] Error reading response %s %s: %s",
|
||||||
|
@ -1137,6 +1147,24 @@ class MatrixFederationHttpClient:
|
||||||
msg,
|
msg,
|
||||||
)
|
)
|
||||||
raise SynapseError(502, msg, Codes.TOO_LARGE)
|
raise SynapseError(502, msg, Codes.TOO_LARGE)
|
||||||
|
except defer.TimeoutError as e:
|
||||||
|
logger.warning(
|
||||||
|
"{%s} [%s] Timed out reading response - %s %s",
|
||||||
|
request.txn_id,
|
||||||
|
request.destination,
|
||||||
|
request.method,
|
||||||
|
request.uri.decode("ascii"),
|
||||||
|
)
|
||||||
|
raise RequestSendFailed(e, can_retry=True) from e
|
||||||
|
except ResponseFailed as e:
|
||||||
|
logger.warning(
|
||||||
|
"{%s} [%s] Failed to read response - %s %s",
|
||||||
|
request.txn_id,
|
||||||
|
request.destination,
|
||||||
|
request.method,
|
||||||
|
request.uri.decode("ascii"),
|
||||||
|
)
|
||||||
|
raise RequestSendFailed(e, can_retry=True) from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"{%s} [%s] Error reading response: %s",
|
"{%s} [%s] Error reading response: %s",
|
||||||
|
|
Loading…
Reference in New Issue