try and fix DNS and socket errors from being retried

This commit is contained in:
Amber H. Brown 2019-06-24 10:36:10 +10:00
parent c59f43d325
commit 0bcdce2237
3 changed files with 10 additions and 5 deletions

View file

@ -194,6 +194,9 @@ class PerDestinationQueue(object):
# We have to keep 2 free slots for presence and rr_edus
limit = MAX_EDUS_PER_TRANSACTION - 2
# Lock before we start doing work
acquired_lock = yield make_deferred_yieldable(self._transaction_manager.limiter.acquire())
device_update_edus, dev_list_id = (
yield self._get_device_update_edus(limit)
)
@ -260,6 +263,7 @@ class PerDestinationQueue(object):
if not pending_pdus and not pending_edus:
logger.debug("TX [%s] Nothing to send", self._destination)
self._last_device_stream_id = device_stream_id
acquired_lock = acquired_lock.release()
return
# if we've decided to send a transaction anyway, and we have room, we
@ -269,11 +273,9 @@ class PerDestinationQueue(object):
# END CRITICAL SECTION
acquired_lock = yield make_deferred_yieldable(self._transaction_manager.limiter.acquire())
success = yield self._transaction_manager.send_new_transaction(
self._destination, pending_pdus, pending_edus
)
acquired_lock = acquired_lock.release()
if success:
sent_transactions_counter.inc()
@ -300,6 +302,9 @@ class PerDestinationQueue(object):
self._last_device_list_stream_id = dev_list_id
else:
break
# Release the lock after all the work is done
acquired_lock = acquired_lock.release()
except NotRetryingDestination as e:
logger.debug(
"TX [%s] not ready for retry yet (next retry at %s) - "

View file

@ -42,7 +42,7 @@ class TransactionManager(object):
# HACK to get unique tx id
self._next_txn_id = int(self.clock.time_msec())
self.limiter = defer.DeferredSemaphore(30)
self.limiter = defer.DeferredSemaphore(50)
LaterGauge(
"synapse_federation_transaction_client_concurrency",

View file

@ -35,7 +35,7 @@ from twisted.internet import defer, protocol
from twisted.internet.error import DNSLookupError, ConnectError, ConnectionRefusedError
from twisted.internet.interfaces import IReactorPluggableNameResolver
from twisted.internet.task import _EPSILON, Cooperator
from twisted.web._newclient import ResponseDone, RequestTransmissionFailed
from twisted.web._newclient import ResponseDone, RequestTransmissionFailed, ResponseNeverReceived
from twisted.web.http_headers import Headers
import synapse.metrics
@ -427,7 +427,7 @@ class MatrixFederationHttpClient(object):
logger.info("Failed to send request due to socket error: %s", e)
raise_from(RequestSendFailed(e, can_retry=True), e)
except RequestTransmissionFailed as e:
except (RequestTransmissionFailed, ResponseNeverReceived) as e:
for i in e.reasons:
# If it's an OpenSSL error, they probably don't have
# a valid certificate or something else very bad went on.