This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Thread through instance name to replication client. #7369
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91d30dc
Thread through instance name to replication client
erikjohnston 6c4292d
Pass instance name through to rdata
erikjohnston 4d74a65
Newsfile
erikjohnston 38cf09d
Add assertion during ReplicationEndpoint construction
erikjohnston f09d4e4
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/in…
erikjohnston 7b00cc9
Review comments
erikjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thread through instance name to replication client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,9 @@ class ReplicationDataHandler: | |
def __init__(self, store: BaseSlavedStore): | ||
self.store = store | ||
|
||
async def on_rdata(self, stream_name: str, token: int, rows: list): | ||
async def on_rdata( | ||
self, stream_name: str, instance_name: str, token: int, rows: list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add |
||
): | ||
"""Called to handle a batch of replication data with a given stream token. | ||
|
||
By default this just pokes the slave store. Can be overridden in subclasses to | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,9 +278,11 @@ async def on_RDATA(self, conn: AbstractConnection, cmd: RdataCommand): | |
# Check if this is the last of a batch of updates | ||
rows = self._pending_batches.pop(stream_name, []) | ||
rows.append(row) | ||
await self.on_rdata(stream_name, cmd.token, rows) | ||
await self.on_rdata(stream_name, cmd.instance_name, cmd.token, rows) | ||
|
||
async def on_rdata(self, stream_name: str, token: int, rows: list): | ||
async def on_rdata( | ||
self, stream_name: str, instance_name: str, token: int, rows: list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the docstring to match the arguments. |
||
): | ||
"""Called to handle a batch of replication data with a given stream token. | ||
|
||
Args: | ||
|
@@ -290,7 +292,9 @@ async def on_rdata(self, stream_name: str, token: int, rows: list): | |
Stream.parse_row. | ||
""" | ||
logger.debug("Received rdata %s -> %s", stream_name, token) | ||
await self._replication_data_handler.on_rdata(stream_name, token, rows) | ||
await self._replication_data_handler.on_rdata( | ||
stream_name, instance_name, token, rows | ||
) | ||
|
||
async def on_POSITION(self, conn: AbstractConnection, cmd: PositionCommand): | ||
if cmd.instance_name == self._instance_name: | ||
|
@@ -325,7 +329,9 @@ async def on_POSITION(self, conn: AbstractConnection, cmd: PositionCommand): | |
updates, | ||
current_token, | ||
missing_updates, | ||
) = await stream.get_updates_since(current_token, cmd.token) | ||
) = await stream.get_updates_since( | ||
cmd.instance_name, current_token, cmd.token | ||
) | ||
|
||
# TODO: add some tests for this | ||
|
||
|
@@ -334,7 +340,10 @@ async def on_POSITION(self, conn: AbstractConnection, cmd: PositionCommand): | |
|
||
for token, rows in _batch_updates(updates): | ||
await self.on_rdata( | ||
cmd.stream_name, token, [stream.parse_row(row) for row in rows], | ||
cmd.stream_name, | ||
cmd.instance_name, | ||
token, | ||
[stream.parse_row(row) for row in rows], | ||
) | ||
|
||
# We've now caught up to position sent to us, notify handler. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: if this is internal it'd be nice to prefix it with an
_
. (The only use I could find was the line above this one.)