Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
b9f61630
Commit
b9f61630
authored
6 years ago
by
Andrew Morgan
Browse files
Options
Downloads
Patches
Plain Diff
Simplify token replication logic
parent
fe7bd23a
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
+14
-23
14 additions, 23 deletions
synapse/replication/tcp/protocol.py
with
14 additions
and
23 deletions
synapse/replication/tcp/protocol.py
+
14
−
23
View file @
b9f61630
...
...
@@ -478,7 +478,7 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
# Now we can send any updates that came in while we were subscribing
pending_rdata
=
self
.
pending_rdata
.
pop
(
stream_name
,
[])
batch_
updates
=
[]
updates
=
[]
for
token
,
update
in
pending_rdata
:
# If the token is null, it is part of a batch update. Batches
# are multiple updates that share a single token. To denote
...
...
@@ -489,34 +489,25 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
# final token.
if
token
is
None
:
# Store this update as part of a batch
batch_
updates
.
append
(
update
)
updates
.
append
(
update
)
continue
if
len
(
batch_updates
)
>
0
:
# There is an ongoing batch and this is the end
if
current_token
<=
current_token
:
# This batch is older than current_token, dismiss it
batch_updates
=
[]
else
:
# This is the end of the batch. Append final update of
# this batch before sending
batch_updates
.
append
(
update
)
# 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
))
# Clear saved batch updates
batch_updates
=
[]
if
token
<=
current_token
:
# This update or batch of updates is older than
# current_token, dismiss it
updates
=
[]
continue
# This is an update that's not part of a batch.
#
# Only send updates newer than the current token
if
token
>
current_token
:
updates
.
append
(
update
)
# Send all updates that are part of this batch with the
# found token
for
update
in
updates
:
self
.
send_command
(
RdataCommand
(
stream_name
,
token
,
update
))
# Clear stored updates
updates
=
[]
# They're now fully subscribed
self
.
replication_streams
.
add
(
stream_name
)
except
Exception
as
e
:
...
...
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