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

Commit

Permalink
Only fetch thread participation for events with threads. (#12228)
Browse files Browse the repository at this point in the history
We fetch the thread summary in two phases:

1. The summary that is shared by all users (count of messages and latest event).
2. Whether the requesting user has participated in the thread.

There's no use in attempting step 2 for events which did not return a summary
from step 1.
  • Loading branch information
clokep authored Mar 18, 2022
1 parent 2177e35 commit 80e0e1f
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 245 deletions.
1 change: 1 addition & 0 deletions changelog.d/12228.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in v1.53.0 where an unnecessary query could be performed when fetching bundled aggregations for threads.
4 changes: 3 additions & 1 deletion synapse/storage/databases/main/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,9 @@ async def get_bundled_aggregations(
summaries = await self._get_thread_summaries(events_by_id.keys())
# Only fetch participated for a limited selection based on what had
# summaries.
participated = await self._get_threads_participated(summaries.keys(), user_id)
participated = await self._get_threads_participated(
[event_id for event_id, summary in summaries.items() if summary], user_id
)
for event_id, summary in summaries.items():
if summary:
thread_count, latest_thread_event, edit = summary
Expand Down
Loading

0 comments on commit 80e0e1f

Please sign in to comment.