diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2021-07-28 10:36:55 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2021-07-28 10:36:55 +0100 |
commit | 1d3a9fe6e5cec793e7e259cf7e469fd4c8d79041 (patch) | |
tree | 7362257c5ff8e37b52334d06ab55d85fabc2dce8 /synapse/storage | |
parent | Merge remote-tracking branch 'origin/release-v1.38' into matrix-org-hotfixes (diff) | |
parent | Fix import of the default SAML mapping provider. (#10477) (diff) | |
download | synapse-1d3a9fe6e5cec793e7e259cf7e469fd4c8d79041.tar.xz |
Merge branch 'release-v1.39' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/end_to_end_keys.py | 9 | ||||
-rw-r--r-- | synapse/storage/databases/main/lock.py | 6 |
2 files changed, 13 insertions, 2 deletions
diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py index 78ae68ec68..1edc96042b 100644 --- a/synapse/storage/databases/main/end_to_end_keys.py +++ b/synapse/storage/databases/main/end_to_end_keys.py @@ -21,6 +21,7 @@ from canonicaljson import encode_canonical_json from twisted.enterprise.adbapi import Connection +from synapse.api.constants import DeviceKeyAlgorithms from synapse.logging.opentracing import log_kv, set_tag, trace from synapse.storage._base import SQLBaseStore, db_to_json from synapse.storage.database import DatabasePool, make_in_list_sql_clause @@ -381,9 +382,15 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore): " GROUP BY algorithm" ) txn.execute(sql, (user_id, device_id)) - result = {} + + # Initially set the key count to 0. This ensures that the client will always + # receive *some count*, even if it's 0. + result = {DeviceKeyAlgorithms.SIGNED_CURVE25519: 0} + + # Override entries with the count of any keys we pulled from the database for algorithm, key_count in txn: result[algorithm] = key_count + return result return await self.db_pool.runInteraction( diff --git a/synapse/storage/databases/main/lock.py b/synapse/storage/databases/main/lock.py index 774861074c..3d1dff660b 100644 --- a/synapse/storage/databases/main/lock.py +++ b/synapse/storage/databases/main/lock.py @@ -78,7 +78,11 @@ class LockStore(SQLBaseStore): """Called when the server is shutting down""" logger.info("Dropping held locks due to shutdown") - for (lock_name, lock_key), token in self._live_tokens.items(): + # We need to take a copy of the tokens dict as dropping the locks will + # cause the dictionary to change. + tokens = dict(self._live_tokens) + + for (lock_name, lock_key), token in tokens.items(): await self._drop_lock(lock_name, lock_key, token) logger.info("Dropped locks due to shutdown") |