From 03db6701d5379f4aa05037bd9ce23942c501874e Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 22 Sep 2021 10:31:05 -0400 Subject: [PATCH] Fix invalidating OTK count cache after claim (#10875) The invalidation was missing in `_claim_e2e_one_time_key_returning`, which is used on SQLite 3.24+ and Postgres. This could break e2ee if nothing else happened to invalidate the caches before the keys ran out. Signed-off-by: Tulir Asokan --- changelog.d/10875.bugfix | 1 + synapse/storage/databases/main/end_to_end_keys.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 changelog.d/10875.bugfix diff --git a/changelog.d/10875.bugfix b/changelog.d/10875.bugfix new file mode 100644 index 000000000..6f370da5c --- /dev/null +++ b/changelog.d/10875.bugfix @@ -0,0 +1 @@ +Fix invalidating one-time key count cache after claiming keys. Contributed by Tulir at Beeper. diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py index 1f0a39eac..a95ac34f0 100644 --- a/synapse/storage/databases/main/end_to_end_keys.py +++ b/synapse/storage/databases/main/end_to_end_keys.py @@ -824,6 +824,10 @@ class EndToEndKeyWorkerStore(EndToEndKeyBackgroundStore): if otk_row is None: return None + self._invalidate_cache_and_stream( + txn, self.count_e2e_one_time_keys, (user_id, device_id) + ) + key_id, key_json = otk_row return f"{algorithm}:{key_id}", key_json