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
Add new columns tracking when we partial-joined #13892
Merged
DMRobertson
merged 8 commits into
develop
from
dmr/faster-joins/outbound-device-list-tracking
Sep 27, 2022
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e986a7f
Add new columns tracking when we partial-joined
de0002b
Store when we partial-joined
270da67
Changelog
b5d67c4
Drop the foreign key constraint :(
0f419d1
stream id column: NOT NULL DEFAULT 0
94ee1e2
Add back the foreign key constraint
be843f7
Fix a bug where dmr 30.3.1 would type w/o thinking
7118e1d
Merge branch 'develop' into dmr/faster-joins/outbound-device-list-tra…
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
Add back the foreign key constraint
- Loading branch information
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
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 |
---|---|---|
|
@@ -1777,7 +1777,6 @@ async def store_partial_state_room( | |
self, | ||
room_id: str, | ||
servers: Collection[str], | ||
join_event_id: str, | ||
device_lists_stream_id: int, | ||
) -> None: | ||
"""Mark the given room as containing events with partial state. | ||
|
@@ -1786,11 +1785,12 @@ async def store_partial_state_room( | |
room, which helps us to keep other homeservers in sync when we finally fully | ||
join this room. | ||
|
||
We do not include a `join_event_id` here---we need to wait for the join event | ||
to be persisted first. | ||
|
||
Args: | ||
room_id: the ID of the room | ||
servers: other servers known to be in the room | ||
join_event_id: the event ID of the join membership event returned in the | ||
(partial) /send_join response. | ||
device_lists_stream_id: the device_lists stream ID at the time when we first | ||
joined the room. | ||
""" | ||
|
@@ -1799,7 +1799,6 @@ async def store_partial_state_room( | |
self._store_partial_state_room_txn, | ||
room_id, | ||
servers, | ||
join_event_id, | ||
device_lists_stream_id, | ||
) | ||
|
||
|
@@ -1808,7 +1807,6 @@ def _store_partial_state_room_txn( | |
txn: LoggingTransaction, | ||
room_id: str, | ||
servers: Collection[str], | ||
join_event_id: str, | ||
device_lists_stream_id: int, | ||
) -> None: | ||
DatabasePool.simple_insert_txn( | ||
|
@@ -1817,7 +1815,8 @@ def _store_partial_state_room_txn( | |
values={ | ||
"room_id": room_id, | ||
"device_lists_stream_id": device_lists_stream_id, | ||
"join_event_id": join_event_id, | ||
# To be updated later once the join event is persisted. | ||
"join_event_id": None, | ||
}, | ||
) | ||
DatabasePool.simple_insert_many_txn( | ||
|
@@ -1828,6 +1827,36 @@ def _store_partial_state_room_txn( | |
) | ||
self._invalidate_cache_and_stream(txn, self.is_partial_state_room, (room_id,)) | ||
|
||
async def write_partial_state_rooms_join_event_id( | ||
self, | ||
room_id: str, | ||
join_event_id: str, | ||
) -> None: | ||
"""Record the join event which resulted from a partial join. | ||
|
||
We do this separately to `store_partial_state_room` because we need to wait for | ||
the join event to be persisted. Otherwise we violate a foreign key constraint. | ||
""" | ||
await self.db_pool.runInteraction( | ||
"write_partial_state_rooms_join_event_id", | ||
self._store_partial_state_room_txn, | ||
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. Also wrong function 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. oh bugger. Why didn't mypy spot that? 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. Because we don't use ParamSpec in synapse.storage.database.py. Will refrain for now but I've found my next brain cleaner. |
||
room_id, | ||
join_event_id, | ||
) | ||
|
||
async def _write_partial_state_rooms_join_event_id( | ||
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 shouldn't be an async def |
||
self, | ||
txn: LoggingTransaction, | ||
room_id: str, | ||
join_event_id: str, | ||
) -> None: | ||
DatabasePool.simple_update_txn( | ||
txn, | ||
table="partial_state_rooms", | ||
keyvalues={"room_id": room_id}, | ||
updatevalues={"join_event_id": join_event_id}, | ||
) | ||
|
||
async def maybe_store_room_on_outlier_membership( | ||
self, room_id: str, room_version: RoomVersion | ||
) -> None: | ||
|
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.
Why do we do this in an
else
block rather than in thetry
or afterwards?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.
My thinking was that
process_remote_join
fails then the event may not be persistedPartialStateConflictError
is catchingHappy to just bung it at the bottom of the
try
though if you prefer.