diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-09-12 20:43:47 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 20:43:47 +1000 |
commit | 33716c4aea130a59f704f08f2bd0c32b013a54d4 (patch) | |
tree | 6186f4595b23cff3a4ea0ba807fa6a8d3e974cd0 /synapse/crypto | |
parent | Merge pull request #3824 from matrix-org/rav/fix_jwt_import (diff) | |
parent | changelog (diff) | |
download | synapse-33716c4aea130a59f704f08f2bd0c32b013a54d4.tar.xz |
Merge pull request #3826 from matrix-org/rav/logging_for_keyring
add some logging for the keyring queue
Diffstat (limited to 'synapse/crypto')
-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 9d497abf17..d89f94c219 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -41,6 +41,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, @@ -217,23 +218,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) |