Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix invalidating OTK count cache after claim (#10875)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tulir authored Sep 22, 2021
1 parent 8f2a527 commit 03db670
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/10875.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invalidating one-time key count cache after claiming keys. Contributed by Tulir at Beeper.
4 changes: 4 additions & 0 deletions synapse/storage/databases/main/end_to_end_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,10 @@ def _claim_e2e_one_time_key_returning(
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

Expand Down

0 comments on commit 03db670

Please sign in to comment.