This repository was 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
Faster room joins: Resume state re-syncing after a Synapse restart #12813
Merged
squahtx
merged 21 commits into
develop
from
squah/faster_room_joins_resume_state_resyncing_on_restart
May 31, 2022
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dd3e926
Raise an InvalidResponseError instead of an Exception when /state_ids…
2d63f45
Document that `FederationError`s get raised from `FederationEventHand…
83a9310
Try other destinations when resyncing the state of a partial-state room
808ad43
Add newsfile
0cb9864
Resume state re-syncing after a Synapse restart
10b29ad
Add newsfile
356f0c3
Merge remote-tracking branch 'origin/develop' into squah/faster_room_…
c713c47
Update docstring for `get_room_state_ids`
ab3ccf7
Rename _sync_partial_state_room parameters
55460da
Complain if 0 destinations have been provided
972a021
Refactor loop to be infinite
ed290b2
Add TODOs
4363bd3
Merge branch 'develop' into squah/faster_room_joins_resync_from_other…
squahtx 3efe1df
Run linter
dd6bf3f
Rename _sync_partial_state_room parameters, part 2
ad48b30
Update synapse/handlers/federation.py
squahtx 58741a3
Update synapse/storage/databases/main/room.py
squahtx 0680f1c
Update synapse/storage/databases/main/room.py
squahtx 861c8e5
Merge branch 'squah/faster_room_joins_resync_from_other_homeservers_o…
6172d86
Fix argument names for _sync_partial_state_room
be40a4f
Merge remote-tracking branch 'origin/develop' into squah/faster_room_…
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 hidden or 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 @@ | ||
| Resume state re-syncing for rooms with partial state after a Synapse restart. |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -169,6 +169,14 @@ def __init__(self, hs: "HomeServer"): | |
|
|
||
| self.third_party_event_rules = hs.get_third_party_event_rules() | ||
|
|
||
| # if this is the main process, fire off a background process to resume | ||
| # any partial-state-resync operations which were in flight when we | ||
| # were shut down. | ||
| if not hs.config.worker.worker_app: | ||
| run_as_background_process( | ||
| "resume_sync_partial_state_room", self._resume_sync_partial_state_room | ||
| ) | ||
|
|
||
| async def maybe_backfill( | ||
| self, room_id: str, current_depth: int, limit: int | ||
| ) -> bool: | ||
|
|
@@ -470,6 +478,8 @@ async def do_invite_join( | |
| """ | ||
| # TODO: We should be able to call this on workers, but the upgrading of | ||
| # room stuff after join currently doesn't work on workers. | ||
| # TODO: Before we relax this condition, we need to allow re-syncing of | ||
| # partial room state to happen on workers. | ||
| assert self.config.worker.worker_app is None | ||
|
|
||
| logger.debug("Joining %s to %s", joinee, room_id) | ||
|
|
@@ -550,8 +560,6 @@ async def do_invite_join( | |
| if ret.partial_state: | ||
| # Kick off the process of asynchronously fetching the state for this | ||
| # room. | ||
| # | ||
| # TODO(faster_joins): pick this up again on restart | ||
| run_as_background_process( | ||
| desc="sync_partial_state_room", | ||
| func=self._sync_partial_state_room, | ||
|
|
@@ -1463,6 +1471,20 @@ async def get_room_complexity( | |
| # well. | ||
| return None | ||
|
|
||
| async def _resume_sync_partial_state_room(self) -> None: | ||
| """Resumes resyncing of all partial-state rooms after a restart.""" | ||
| assert not self.config.worker.worker_app | ||
|
|
||
| partial_state_rooms = await self.store.get_partial_state_rooms_and_servers() | ||
| for room_id, servers_in_room in partial_state_rooms.items(): | ||
| run_as_background_process( | ||
| desc="sync_partial_state_room", | ||
| func=self._sync_partial_state_room, | ||
| initial_destination=None, | ||
| other_destinations=servers_in_room, | ||
| room_id=room_id, | ||
| ) | ||
|
|
||
| async def _sync_partial_state_room( | ||
| self, | ||
| initial_destination: Optional[str], | ||
|
|
@@ -1477,6 +1499,7 @@ async def _sync_partial_state_room( | |
| `initial_destination` is unavailable | ||
| room_id: room to be resynced | ||
| """ | ||
| assert not self.config.worker.worker_app | ||
|
Contributor
Author
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. This is implied by the identical assert in |
||
|
|
||
| # TODO(faster_joins): do we need to lock to avoid races? What happens if other | ||
| # worker processes kick off a resync in parallel? Perhaps we should just elect | ||
|
|
||
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.