diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py index 2a7dd343f..aac6f1c16 100644 --- a/synapse/federation/transaction_queue.py +++ b/synapse/federation/transaction_queue.py @@ -203,6 +203,17 @@ class TransactionQueue(object): @log_function def _attempt_new_transaction(self, destination): # list of (pending_pdu, deferred, order) + if destination in self.pending_transactions: + # XXX: pending_transactions can get stuck on by a never-ending + # request at which point pending_pdus_by_dest just keeps growing. + # we need application-layer timeouts of some flavour of these + # requests + logger.debug( + "TX [%s] Transaction already in progress", + destination + ) + return + pending_pdus = self.pending_pdus_by_dest.pop(destination, []) pending_edus = self.pending_edus_by_dest.pop(destination, []) pending_failures = self.pending_failures_by_dest.pop(destination, []) @@ -215,18 +226,6 @@ class TransactionQueue(object): logger.debug("TX [%s] Nothing to send", destination) return - if destination in self.pending_transactions: - # XXX: pending_transactions can get stuck on by a never-ending - # request at which point pending_pdus_by_dest just keeps growing. - # we need application-layer timeouts of some flavour of these - # requests - logger.debug( - "TX [%s] Transaction already in progress", - destination - ) - return - - # NOTE: Nothing should be between the above check and the insertion below try: self.pending_transactions[destination] = 1