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

Commit 80e0e1f

Browse files
authored
Only fetch thread participation for events with threads. (#12228)
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.
1 parent 2177e35 commit 80e0e1f

File tree

4 files changed

+289
-245
lines changed

4 files changed

+289
-245
lines changed

changelog.d/12228.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug introduced in v1.53.0 where an unnecessary query could be performed when fetching bundled aggregations for threads.

synapse/storage/databases/main/relations.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,9 @@ async def get_bundled_aggregations(
857857
summaries = await self._get_thread_summaries(events_by_id.keys())
858858
# Only fetch participated for a limited selection based on what had
859859
# summaries.
860-
participated = await self._get_threads_participated(summaries.keys(), user_id)
860+
participated = await self._get_threads_participated(
861+
[event_id for event_id, summary in summaries.items() if summary], user_id
862+
)
861863
for event_id, summary in summaries.items():
862864
if summary:
863865
thread_count, latest_thread_event, edit = summary

0 commit comments

Comments
 (0)