mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-03 00:44:49 -04:00
Add ability to shard the federation sender (#7798)
This commit is contained in:
parent
f1245dc3c0
commit
f299441cc6
15 changed files with 670 additions and 157 deletions
|
@ -74,6 +74,20 @@ class PerDestinationQueue(object):
|
|||
self._clock = hs.get_clock()
|
||||
self._store = hs.get_datastore()
|
||||
self._transaction_manager = transaction_manager
|
||||
self._instance_name = hs.get_instance_name()
|
||||
self._federation_shard_config = hs.config.federation.federation_shard_config
|
||||
|
||||
self._should_send_on_this_instance = True
|
||||
if not self._federation_shard_config.should_send_to(
|
||||
self._instance_name, destination
|
||||
):
|
||||
# We don't raise an exception here to avoid taking out any other
|
||||
# processing. We have a guard in `attempt_new_transaction` that
|
||||
# ensure we don't start sending stuff.
|
||||
logger.error(
|
||||
"Create a per destination queue for %s on wrong worker", destination,
|
||||
)
|
||||
self._should_send_on_this_instance = False
|
||||
|
||||
self._destination = destination
|
||||
self.transmission_loop_running = False
|
||||
|
@ -180,6 +194,14 @@ class PerDestinationQueue(object):
|
|||
logger.debug("TX [%s] Transaction already in progress", self._destination)
|
||||
return
|
||||
|
||||
if not self._should_send_on_this_instance:
|
||||
# We don't raise an exception here to avoid taking out any other
|
||||
# processing.
|
||||
logger.error(
|
||||
"Trying to start a transaction to %s on wrong worker", self._destination
|
||||
)
|
||||
return
|
||||
|
||||
logger.debug("TX [%s] Starting transaction loop", self._destination)
|
||||
|
||||
run_as_background_process(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue