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
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
84ce93c1
Unverified
Commit
84ce93c1
authored
2 years ago
by
Erik Johnston
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix race calling `/members?at=` (#14817)
Fixes #14814
parent
3952297f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/14817.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/14817.bugfix
synapse/storage/databases/main/stream.py
+59
-6
59 additions, 6 deletions
synapse/storage/databases/main/stream.py
with
60 additions
and
6 deletions
changelog.d/14817.bugfix
0 → 100644
+
1
−
0
View file @
84ce93c1
Fix race where calling `/members` or `/state` with an `at` parameter could fail for newly created rooms, when using multiple workers.
This diff is collapsed.
Click to expand it.
synapse/storage/databases/main/stream.py
+
59
−
6
View file @
84ce93c1
...
...
@@ -801,13 +801,66 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
before this stream ordering.
"""
last_row
=
await
self
.
get_room_event_before_stream_ordering
(
room_id
=
room_id
,
stream_ordering
=
end_token
.
stream
,
def
get_last_event_in_room_before_stream_ordering_txn
(
txn
:
LoggingTransaction
,
)
->
Optional
[
str
]:
# We need to handle the fact that the stream tokens can be vector
# clocks. We do this by getting all rows between the minimum and
# maximum stream ordering in the token, plus one row less than the
# minimum stream ordering. We then filter the results against the
# token and return the first row that matches.
sql
=
"""
SELECT * FROM (
SELECT instance_name, stream_ordering, topological_ordering, event_id
FROM events
LEFT JOIN rejections USING (event_id)
WHERE room_id = ?
AND ? < stream_ordering AND stream_ordering <= ?
AND NOT outlier
AND rejections.event_id IS NULL
ORDER BY stream_ordering DESC
) AS a
UNION
SELECT * FROM (
SELECT instance_name, stream_ordering, topological_ordering, event_id
FROM events
LEFT JOIN rejections USING (event_id)
WHERE room_id = ?
AND stream_ordering <= ?
AND NOT outlier
AND rejections.event_id IS NULL
ORDER BY stream_ordering DESC
LIMIT 1
) AS b
"""
txn
.
execute
(
sql
,
(
room_id
,
end_token
.
stream
,
end_token
.
get_max_stream_pos
(),
room_id
,
end_token
.
stream
,
),
)
for
instance_name
,
stream_ordering
,
topological_ordering
,
event_id
in
txn
:
if
_filter_results
(
lower_token
=
None
,
upper_token
=
end_token
,
instance_name
=
instance_name
,
topological_ordering
=
topological_ordering
,
stream_ordering
=
stream_ordering
,
):
return
event_id
return
None
return
await
self
.
db_pool
.
runInteraction
(
"
get_last_event_in_room_before_stream_ordering
"
,
get_last_event_in_room_before_stream_ordering_txn
,
)
if
last_row
:
return
last_row
[
2
]
return
None
async
def
get_current_room_stream_token_for_room_id
(
self
,
room_id
:
str
...
...
This diff is collapsed.
Click to expand it.
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