-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reduce spurious replication catchup #16555
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reduce some spurious logging in worker mode. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -611,10 +611,14 @@ async def _process_position( | |||||||||||||||||||||||||
# Find where we previously streamed up to. | ||||||||||||||||||||||||||
current_token = stream.current_token(cmd.instance_name) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# If the position token matches our current token then we're up to | ||||||||||||||||||||||||||
# date and there's nothing to do. Otherwise, fetch all updates | ||||||||||||||||||||||||||
# between then and now. | ||||||||||||||||||||||||||
missing_updates = cmd.prev_token != current_token | ||||||||||||||||||||||||||
# If the position token matches our current token then we're up to date | ||||||||||||||||||||||||||
# and there's nothing to do. Otherwise, fetch all updates between then | ||||||||||||||||||||||||||
# and now. | ||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||
# Note: We have to check that `current_token` is within the range, to | ||||||||||||||||||||||||||
# handle the case where the stream gets "reset" (e.g. for `caches` and | ||||||||||||||||||||||||||
# `typing` after the writer's restart). | ||||||||||||||||||||||||||
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.
Suggested change
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. Example: I think the stream is at position 10. (Here current < prev < next.) 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.
You might have missed entries 11 and 12. 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. Does 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. https://matrix-org.github.io/synapse/develop/tcp_replication.html#position-s probably needs to be updated too 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. (Not blocking this PR, but would appreciate a follow-up or at least an issue.) 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. #16560 since its a Friday afternoon and I'm liable to forget to follow up otherwise 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.
Suggested change
|
||||||||||||||||||||||||||
missing_updates = not (cmd.prev_token <= current_token <= cmd.new_token) | ||||||||||||||||||||||||||
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. Sanity check: are the inequalities correct here? E.g. should one of them be 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. Good point that it looks weird. But I think they're right as we're comparing "upper bounds" |
||||||||||||||||||||||||||
while missing_updates: | ||||||||||||||||||||||||||
# Note: There may very well not be any new updates, but we check to | ||||||||||||||||||||||||||
# make sure. This can particularly happen for the event stream where | ||||||||||||||||||||||||||
|
@@ -644,7 +648,7 @@ async def _process_position( | |||||||||||||||||||||||||
[stream.parse_row(row) for row in rows], | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
logger.info("Caught up with stream '%s' to %i", stream_name, cmd.new_token) | ||||||||||||||||||||||||||
logger.info("Caught up with stream '%s' to %i", stream_name, current_token) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# We've now caught up to position sent to us, notify handler. | ||||||||||||||||||||||||||
await self._replication_data_handler.on_position( | ||||||||||||||||||||||||||
|
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.
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.
Example: I think the stream is at position 10.
I receive
POSITION 4 8
.Uh oh, I might have missed stream entries 5, 6, 7 and 8. Need to rescan for them.
(Here prev < next < current.)
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.
Ah, no.
POSITION 4 8
means that the new token for that instance should be set to 8, and nothing has happened between 4 and 8 from that instance. (The reason for this is that normally we'd just get a stream ofRDATA
from the instance, which implicitly bumps the token. If for some reason the token has advanced without any updates to send, it sends aPOSITION
, hence why it gives the range where things have not happened).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.
Maybe?