-
Notifications
You must be signed in to change notification settings - Fork 359
Sliding sync: use new DB tables #17630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
74bec29
58071bc
c9a9156
e2c0a4b
86a0730
c038ff9
a278a67
a027397
676754d
bc4cb1f
bfd36c1
ed4ce95
2980422
6c4ad32
5d6386a
acb57ee
82f58bf
e76954b
f78ab68
e923a8d
3c9d994
ed4a158
180d176
b3676c4
b88df94
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 @@ | ||
Use new database tables for sliding sync. |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,12 @@ | |
from synapse.storage.databases.main.cache import CacheInvalidationWorkerStore | ||
from synapse.storage.databases.main.events_worker import EventsWorkerStore | ||
from synapse.storage.engines import Sqlite3Engine | ||
from synapse.storage.roommember import MemberSummary, ProfileInfo, RoomsForUser | ||
from synapse.storage.roommember import ( | ||
MemberSummary, | ||
ProfileInfo, | ||
RoomsForUser, | ||
RoomsForUserSlidingSync, | ||
) | ||
from synapse.types import ( | ||
JsonDict, | ||
PersistedEventPosition, | ||
|
@@ -1377,6 +1382,54 @@ async def update_room_forgetter_stream_pos(self, stream_id: int) -> None: | |
desc="room_forgetter_stream_pos", | ||
) | ||
|
||
@cached(iterable=True, max_entries=10000) | ||
async def get_sliding_sync_rooms_for_user( | ||
self, | ||
user_id: str, | ||
) -> Mapping[str, RoomsForUserSlidingSync]: | ||
"""Get all the rooms for a user to handle a sliding sync request. | ||
|
||
Ignores forgotten rooms and rooms that the user has been kicked from. | ||
|
||
Returns: | ||
Map from room ID to membership info | ||
""" | ||
|
||
def get_sliding_sync_rooms_for_user_txn( | ||
txn: LoggingTransaction, | ||
) -> Dict[str, RoomsForUserSlidingSync]: | ||
sql = """ | ||
SELECT m.room_id, m.sender, m.membership, m.membership_event_id, | ||
r.room_version, | ||
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. It looks like we're simply fetching out
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 could be addressed in a future PR. Probably would be good to create an issue for this one 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. Ah, yeah. So, I had the same thought about removing it, but it turns out that sync v2 specifically checks that the room version is known and so we should probably do something similar in sliding sync as well. |
||
m.event_instance_name, m.event_stream_ordering, | ||
COALESCE(j.room_type, m.room_type), | ||
COALESCE(j.is_encrypted, m.is_encrypted) | ||
FROM sliding_sync_membership_snapshots AS m | ||
INNER JOIN rooms AS r USING (room_id) | ||
LEFT JOIN sliding_sync_joined_rooms AS j ON (j.room_id = m.room_id AND m.membership = 'join') | ||
WHERE user_id = ? | ||
AND m.forgotten = 0 | ||
""" | ||
txn.execute(sql, (user_id,)) | ||
return { | ||
row[0]: RoomsForUserSlidingSync( | ||
room_id=row[0], | ||
sender=row[1], | ||
membership=row[2], | ||
event_id=row[3], | ||
room_version_id=row[4], | ||
event_pos=PersistedEventPosition(row[5], row[6]), | ||
room_type=row[7], | ||
is_encrypted=row[8], | ||
) | ||
for row in txn | ||
} | ||
|
||
return await self.db_pool.runInteraction( | ||
"get_sliding_sync_rooms_for_user", | ||
get_sliding_sync_rooms_for_user_txn, | ||
) | ||
|
||
|
||
class RoomMemberBackgroundUpdateStore(SQLBaseStore): | ||
def __init__( | ||
|
Uh oh!
There was an error while loading. Please reload this page.