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
5f0c449d
Commit
5f0c449d
authored
6 years ago
by
Andrew Morgan
Browse files
Options
Downloads
Patches
Plain Diff
Prevent replication wedging
parent
1beebe91
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/replication/tcp/protocol.py
+24
-4
24 additions, 4 deletions
synapse/replication/tcp/protocol.py
with
24 additions
and
4 deletions
synapse/replication/tcp/protocol.py
+
24
−
4
View file @
5f0c449d
...
@@ -451,7 +451,7 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
...
@@ -451,7 +451,7 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
subscribe_to_stream
(
self
,
stream_name
,
token
):
def
subscribe_to_stream
(
self
,
stream_name
,
token
):
"""
Subscribe the remote to a stream
s
.
"""
Subscribe the remote to a stream.
This invloves checking if they
'
ve missed anything and sending those
This invloves checking if they
'
ve missed anything and sending those
updates down if they have. During that time new updates for the stream
updates down if they have. During that time new updates for the stream
...
@@ -478,10 +478,30 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
...
@@ -478,10 +478,30 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
# Now we can send any updates that came in while we were subscribing
# Now we can send any updates that came in while we were subscribing
pending_rdata
=
self
.
pending_rdata
.
pop
(
stream_name
,
[])
pending_rdata
=
self
.
pending_rdata
.
pop
(
stream_name
,
[])
batch_updates
=
[]
for
token
,
update
in
pending_rdata
:
for
token
,
update
in
pending_rdata
:
# Only send updates newer than the current token
# If the token is null, it is part of a batch update. Batches
if
token
>
current_token
:
# are multiple updates that share a single token. To denote
self
.
send_command
(
RdataCommand
(
stream_name
,
token
,
update
))
# this, the token is set to None for all tokens in the batch
# except for the last. If we find a None token, we keep looking
# through tokens until we find one that is not None and then
# process all previous updates in the batch as if they had the
# final token.
if
not
token
or
len
(
batch_updates
)
>
0
:
batch_updates
.
append
(
update
)
if
token
and
not
token
>
current_token
:
# This batch is older than current_token, dismiss
batch_updates
=
[]
continue
if
token
:
# Send all updates that are part of this batch with the
# found token
for
update
in
batch_updates
:
self
.
send_command
(
RdataCommand
(
stream_name
,
token
,
update
))
else
:
# Only send updates newer than the current token
if
token
>
current_token
:
self
.
send_command
(
RdataCommand
(
stream_name
,
token
,
update
))
# They're now fully subscribed
# They're now fully subscribed
self
.
replication_streams
.
add
(
stream_name
)
self
.
replication_streams
.
add
(
stream_name
)
...
...
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