diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-09-06 18:51:06 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-09-06 18:51:06 +0100 |
commit | 806964b5de3e5036a897d4b5d477e7616779d019 (patch) | |
tree | 6eadad13594571224d3a310b3471fc927bee2d75 /synapse | |
parent | Merge branch 'master' into develop (diff) | |
download | synapse-806964b5de3e5036a897d4b5d477e7616779d019.tar.xz |
add some logging for the keyring queue
why is it so damn slow?
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/crypto/keyring.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 30e2742102..a6b31e8b5b 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -40,6 +40,7 @@ from synapse.api.errors import Codes, SynapseError from synapse.crypto.keyclient import fetch_server_key from synapse.util import logcontext, unwrapFirstError from synapse.util.logcontext import ( + LoggingContext, PreserveLoggingContext, preserve_fn, run_in_background, @@ -216,23 +217,34 @@ class Keyring(object): servers have completed. Follows the synapse rules of logcontext preservation. """ + loop_count = 1 while True: wait_on = [ - self.key_downloads[server_name] + (server_name, self.key_downloads[server_name]) for server_name in server_names if server_name in self.key_downloads ] - if wait_on: - with PreserveLoggingContext(): - yield defer.DeferredList(wait_on) - else: + if not wait_on: break + logger.info( + "Waiting for existing lookups for %s to complete [loop %i]", + [w[0] for w in wait_on], loop_count, + ) + with PreserveLoggingContext(): + yield defer.DeferredList((w[1] for w in wait_on)) + + loop_count += 1 + + ctx = LoggingContext.current_context() def rm(r, server_name_): - self.key_downloads.pop(server_name_, None) + with PreserveLoggingContext(ctx): + logger.debug("Releasing key lookup lock on %s", server_name_) + self.key_downloads.pop(server_name_, None) return r for server_name, deferred in server_to_deferred.items(): + logger.debug("Got key lookup lock on %s", server_name) self.key_downloads[server_name] = deferred deferred.addBoth(rm, server_name) |