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
Track unconverted device list outbound pokes using a position instead #14516
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23befb4
Add table to track position of last converted device list change
437d6d1
Use (stream id, room id) position to fetch unconverted device changes
4c6fd81
Stop updating the `converted_to_destinations` column
ddc9999
Add newsfile
9e70ba6
Fix `simple_select_one_txn` to handle empty `WHERE` clause
112bc78
fixup: use tuple comparison in query
b9b2f04
fixup: remove todo
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 @@ | ||
Refactor conversion of device list changes in room to outbound pokes to track unconverted rows using a `(stream ID, room ID)` position instead of updating the `converted_to_destinations` flag on every row. |
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
53 changes: 53 additions & 0 deletions
53
synapse/storage/schema/main/delta/73/12refactor_device_list_outbound_pokes.sql
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,53 @@ | ||
/* Copyright 2022 The Matrix.org Foundation C.I.C | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
-- Prior to this schema delta, we tracked the set of unconverted rows in | ||
-- `device_lists_changes_in_room` using the `converted_to_destinations` flag. When rows | ||
-- were converted to `device_lists_outbound_pokes`, the `converted_to_destinations` flag | ||
-- would be set. | ||
-- | ||
-- After this schema delta, the `converted_to_destinations` is still populated like | ||
-- before, but the set of unconverted rows is determined by the `stream_id` in the new | ||
-- `device_lists_changes_converted_stream_position` table. | ||
-- | ||
-- If rolled back, Synapse will re-send all device list changes that happened since the | ||
-- schema delta. | ||
|
||
CREATE TABLE IF NOT EXISTS device_lists_changes_converted_stream_position( | ||
Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE, -- Makes sure this table only has one row. | ||
-- The (stream id, room id) of the last row in `device_lists_changes_in_room` that | ||
-- has been converted to `device_lists_outbound_pokes`. Rows with a strictly larger | ||
-- (stream id, room id) where `converted_to_destinations` is `FALSE` have not been | ||
-- converted. | ||
stream_id BIGINT NOT NULL, | ||
-- `room_id` may be an empty string, which compares less than all valid room IDs. | ||
room_id TEXT NOT NULL, | ||
CHECK (Lock='X') | ||
); | ||
|
||
INSERT INTO device_lists_changes_converted_stream_position (stream_id, room_id) VALUES ( | ||
( | ||
SELECT COALESCE( | ||
-- The last converted stream id is the smallest unconverted stream id minus | ||
-- one. | ||
MIN(stream_id) - 1, | ||
-- If there is no unconverted stream id, the last converted stream id is the | ||
-- largest stream id. | ||
-- Otherwise, pick 1, since stream ids start at 2. | ||
(SELECT COALESCE(MAX(stream_id), 1) FROM device_lists_changes_in_room) | ||
) FROM device_lists_changes_in_room WHERE NOT converted_to_destinations | ||
), | ||
'' | ||
); |
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 are we removing these? Is these baths no longer used?
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.
Yes, pretty much. After removing the update to
converted_to_destinations
, we haveThe
if not hosts
branch does nothing inside the transaction, so I removed it entirely.