-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make the get_global_account_data_by_type_for_user
cache be a tree-cache whose key is prefixed with the user ID
#11788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove account data (including client config, push rules and ignored users) upon user deactivation. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -158,9 +158,9 @@ def get_account_data_for_user_txn( | |||||||
"get_account_data_for_user", get_account_data_for_user_txn | ||||||||
) | ||||||||
|
||||||||
@cached(num_args=2, max_entries=5000) | ||||||||
@cached(num_args=2, max_entries=5000, tree=True) | ||||||||
async def get_global_account_data_by_type_for_user( | ||||||||
self, data_type: str, user_id: str | ||||||||
self, user_id: str, data_type: str | ||||||||
) -> Optional[JsonDict]: | ||||||||
""" | ||||||||
Returns: | ||||||||
|
@@ -392,7 +392,7 @@ def process_replication_rows( | |||||||
for row in rows: | ||||||||
if not row.room_id: | ||||||||
self.get_global_account_data_by_type_for_user.invalidate( | ||||||||
(row.data_type, row.user_id) | ||||||||
(row.user_id, row.data_type) | ||||||||
) | ||||||||
self.get_account_data_for_user.invalidate((row.user_id,)) | ||||||||
self.get_account_data_for_room.invalidate((row.user_id, row.room_id)) | ||||||||
|
@@ -476,7 +476,7 @@ async def add_account_data_for_user( | |||||||
self._account_data_stream_cache.entity_has_changed(user_id, next_id) | ||||||||
self.get_account_data_for_user.invalidate((user_id,)) | ||||||||
self.get_global_account_data_by_type_for_user.invalidate( | ||||||||
(account_data_type, user_id) | ||||||||
(user_id, account_data_type) | ||||||||
) | ||||||||
Comment on lines
478
to
480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The room case of this seems to prefill instead of invalidate, weirdly. I think this change is fine though, just noting a discrepancy: synapse/synapse/storage/databases/main/account_data.py Lines 444 to 446 in 3e0536c
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a little bit odd, but it does seem correct either way — maybe it was an intentional optimisation, maybe it's just inconsistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think prefilling would be a bit of an optimization, but probably not worth it. 🤷 |
||||||||
|
||||||||
return self._account_data_id_gen.get_current_token() | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this interact with the caching? It uses kwargs so I don't know how our caching handles that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cached functions just base it off name, so this should work OK. I would be fine with you making them into normal args if you'd prefer though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug in to the (slightly confusing) code a bit and it looks like you're right :). Good to know.