summary refs log tree commit diff
path: root/synapse/handlers/pagination.py
diff options
context:
space:
mode:
authorJason Little <j.little@famedly.com>2025-04-30 09:29:42 -0500
committerRory& <root@rory.gay>2025-06-27 19:46:32 +0200
commit99b146825a1a8257d05440ae3e331c68b8e1575a (patch)
tree55b3d414471e6935bd79a614a6b01fe17141f65a /synapse/handlers/pagination.py
parentExpose tombstone in room admin api (diff)
downloadsynapse-99b146825a1a8257d05440ae3e331c68b8e1575a.tar.xz
fix: Always recheck `/messages` pagination data if a backfill might have been needed (#28)
Diffstat (limited to 'synapse/handlers/pagination.py')
-rw-r--r--synapse/handlers/pagination.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py

index 4070b74b7a..81cda38549 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py
@@ -577,27 +577,31 @@ class PaginationHandler: or missing_too_many_events or not_enough_events_to_fill_response ): - did_backfill = await self.hs.get_federation_handler().maybe_backfill( + # Historical Note: There used to be a check here for if backfill was + # successful or not + await self.hs.get_federation_handler().maybe_backfill( room_id, curr_topo, limit=pagin_config.limit, ) - # If we did backfill something, refetch the events from the database to - # catch anything new that might have been added since we last fetched. - if did_backfill: - ( - events, - next_key, - _, - ) = await self.store.paginate_room_events_by_topological_ordering( - room_id=room_id, - from_key=from_token.room_key, - to_key=to_room_key, - direction=pagin_config.direction, - limit=pagin_config.limit, - event_filter=event_filter, - ) + # Regardless if we backfilled or not, another worker or even a + # simultaneous request may have backfilled for us while we were held + # behind the linearizer. This should not have too much additional + # database load as it will only be triggered if a backfill *might* have + # been needed + ( + events, + next_key, + _, + ) = await self.store.paginate_room_events_by_topological_ordering( + room_id=room_id, + from_key=from_token.room_key, + to_key=to_room_key, + direction=pagin_config.direction, + limit=pagin_config.limit, + event_filter=event_filter, + ) else: # Otherwise, we can backfill in the background for eventual # consistency's sake but we don't need to block the client waiting