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
Add some miscellaneous comments around sync #13474
Merged
+81
−40
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ea33ee0
Add some miscellaneous comments around sync
d9607ef
Update synapse/handlers/sync.py
squahtx 1d2ff88
Update synapse/handlers/sync.py
squahtx c15c94e
Rename state variables in `compute_state_delta`
ccec65d
Update stale comment
bcaa6af
fixup rename mention of p_ids in comments
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 @@ | ||
Add some miscellaneous comments to document sync, especially around `compute_state_delta`. |
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
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.
I think?
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.
Is this true for all three sync types?
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.
I believe so?
Assuming the docstring for the return value is right,
state_ids
(which is almost the return value) has to have that property after all three branches, otherwise lazy loading would be broken (this reasoning is a little backwards).It's a lot more confusing to try to reason forwards:
For an initial sync,
state_ids
must include the memberships of event senders, otherwise it's not an initial sync?Less handwavey:
current_state_ids
contains the memberships of event senders at the end of the timeline, andstate_ids
initially contains the memberships of event senders as seen at the start of the timeline. The branch for empty timelines can be ignored because there are no event senders in that case._calculate_state
returns(timeline end state | timeline start state) - (previous sync state - memberships in timeline start) - state in timeline
. The previous sync state is{}
, so_calculate_state
returns the memberships of event senders from the state at the start of the timeline.For a gappy sync:
state_at_timeline_start
contains the memberships of event senders at the start of the timelinestate_at_previous_sync
contains all memberships at the end of the previous synccurrent_state_ids
contains all memberships at the end of the timeline._calculate_state
returns(timeline end state | timeline start state) - (previous sync state - memberships in timeline start) - state in timeline
.The
previous sync state - memberships in timeline start
term excludes the memberships of event senders.(this branch is a mess)
For an incremental sync, we fetch the memberships of event senders explicitly.
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.
I'm somewhat tempted to rename some of these variables...
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.
ok, yes, that sounds right - thank you for ploughing through that!