diff options
author | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2023-02-17 11:11:29 +0000 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2023-03-16 11:45:14 +0000 |
commit | 04d091fbcb466ffb1b3462a7fb8754952044aa24 (patch) | |
tree | 5f3e4b73ddbbfaf4cd9f2dfaee4a8ee1b7faf3af | |
parent | Rename method to make obvious it only applies to local users (diff) | |
download | synapse-04d091fbcb466ffb1b3462a7fb8754952044aa24.tar.xz |
Add another temporary table to the user directory background update for storing remote users needing lookup
-rw-r--r-- | synapse/storage/databases/main/user_directory.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/user_directory.py b/synapse/storage/databases/main/user_directory.py index f2f618c8fd..45127deecd 100644 --- a/synapse/storage/databases/main/user_directory.py +++ b/synapse/storage/databases/main/user_directory.py @@ -142,6 +142,18 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore): txn, TEMP_TABLE + "_users", keys=("user_id",), values=users ) + # A table for storing a list of remote users that *may* need a remote + # lookup in order to obtain a public profile. + # The list should be compared against the user directory's cache + # to see whether any queries can be skipped because the remote user + # also appeared in a public room. + sql = ( + "CREATE TABLE IF NOT EXISTS " + + TEMP_TABLE + + "_remote_users_needing_lookup(user_id TEXT PRIMARY KEY NOT NULL)" + ) + txn.execute(sql) + new_pos = await self.get_max_stream_id_in_current_state_deltas() await self.db_pool.runInteraction( "populate_user_directory_temp_build", _make_staging_area @@ -171,6 +183,9 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore): def _delete_staging_area(txn: LoggingTransaction) -> None: txn.execute("DROP TABLE IF EXISTS " + TEMP_TABLE + "_rooms") txn.execute("DROP TABLE IF EXISTS " + TEMP_TABLE + "_users") + txn.execute( + "DROP TABLE IF EXISTS " + TEMP_TABLE + "_remote_users_needing_lookup" + ) txn.execute("DROP TABLE IF EXISTS " + TEMP_TABLE + "_position") await self.db_pool.runInteraction( |