Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
a3c49565
Commit
a3c49565
authored
7 months ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Look for bump stamp in the room timeline
This allows us to skip checking the database a lot of the time.
parent
5389374e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/sliding_sync/__init__.py
+24
-12
24 additions, 12 deletions
synapse/handlers/sliding_sync/__init__.py
with
24 additions
and
12 deletions
synapse/handlers/sliding_sync/__init__.py
+
24
−
12
View file @
a3c49565
...
@@ -1045,24 +1045,36 @@ class SlidingSyncHandler:
...
@@ -1045,24 +1045,36 @@ class SlidingSyncHandler:
# Figure out the last bump event in the room if we're in the room.
# Figure out the last bump event in the room if we're in the room.
if
room_membership_for_user_at_to_token
.
membership
==
Membership
.
JOIN
:
if
room_membership_for_user_at_to_token
.
membership
==
Membership
.
JOIN
:
last_bump_event_result
=
(
new_bump_stamp
:
Optional
[
int
]
=
None
await
self
.
store
.
get_last_event_pos_in_room_before_stream_ordering
(
room_id
,
# First check the timeline events we're returning to see if one of
to_token
.
room_key
,
# those matches. We iterate backwards and take the stream ordering
event_types
=
SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES
,
# of the first event that matches the bump event types.
for
timeline_event
in
reversed
(
timeline_events
):
if
timeline_event
.
type
in
SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES
:
new_bump_stamp
=
timeline_event
.
internal_metadata
.
stream_ordering
break
else
:
# If not then we query the DB for it.
last_bump_event_result
=
(
await
self
.
store
.
get_last_event_pos_in_room_before_stream_ordering
(
room_id
,
to_token
.
room_key
,
event_types
=
SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES
,
)
)
)
)
if
last_bump_event_result
is
not
None
:
_
,
new_bump_event_pos
=
last_bump_event_result
# But if we found a bump event, use that instead
new_bump_stamp
=
new_bump_event_pos
.
stream
if
last_bump_event_result
is
not
None
:
_
,
new_bump_event_pos
=
last_bump_event_result
# If we found a bump event, use that instead
if
new_bump_stamp
is
not
None
:
# If we've just joined a remote room, then the last bump event may
# If we've just joined a remote room, then the last bump event may
# have been backfilled (and so have a negative stream ordering).
# have been backfilled (and so have a negative stream ordering).
# These negative stream orderings can't sensibly be compared, so
# These negative stream orderings can't sensibly be compared, so
# instead we use the membership event position.
# instead we use the membership event position.
if
new_bump_
event_pos
.
stre
am
>
0
:
if
new_bump_
st
am
p
>
0
:
bump_stamp
=
new_bump_
event_pos
.
stre
am
bump_stamp
=
new_bump_
st
am
p
unstable_expanded_timeline
=
False
unstable_expanded_timeline
=
False
prev_room_sync_config
=
previous_connection_state
.
room_configs
.
get
(
room_id
)
prev_room_sync_config
=
previous_connection_state
.
room_configs
.
get
(
room_id
)
...
...
This diff is collapsed.
Click to expand it.
Tulir Asokan
@tulir
mentioned in commit
5c229415
·
7 months ago
mentioned in commit
5c229415
mentioned in commit 5c229415c482f15a7f45b839ceaed0cbc723057c
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment