From 26a27e06b960e30e2f4f0a5054ffdacc848150c9 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 15:57:55 +0100 Subject: Create the index in a background update --- synapse/storage/profile.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 04908cbc35..919b1f1641 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,12 +19,12 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo -from ._base import SQLBaseStore +from . import background_updates BATCH_SIZE = 100 -class ProfileWorkerStore(SQLBaseStore): +class ProfileWorkerStore(background_updates.BackgroundUpdateStore): @defer.inlineCallbacks def get_profileinfo(self, user_localpart): try: @@ -166,6 +166,17 @@ class ProfileWorkerStore(SQLBaseStore): class ProfileStore(ProfileWorkerStore): + def __init__(self, db_conn, hs): + + super(ProfileStore, self).__init__(db_conn, hs) + + self.register_background_index_update( + "profile_replication_status_host_index", + index_name="profile_replication_status_idx", + table="profile_replication_status", + columns=["host"], + ) + def add_remote_profile_cache(self, user_id, displayname, avatar_url): """Ensure we are caching the remote user's profiles. -- cgit 1.5.1 From 27cd0b3037b439337a54de370a52be671ff4198d Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 17:40:14 +0100 Subject: Fix snafu --- synapse/storage/profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 919b1f1641..23c4c31669 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,12 +19,13 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo +from ._base import SQLBaseStore from . import background_updates BATCH_SIZE = 100 -class ProfileWorkerStore(background_updates.BackgroundUpdateStore): +class ProfileWorkerStore(SQLBaseStore): @defer.inlineCallbacks def get_profileinfo(self, user_localpart): try: @@ -165,7 +166,7 @@ class ProfileWorkerStore(background_updates.BackgroundUpdateStore): ) -class ProfileStore(ProfileWorkerStore): +class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore): def __init__(self, db_conn, hs): super(ProfileStore, self).__init__(db_conn, hs) -- cgit 1.5.1 From 996cf15d4250535398df351621eb03ee29446c9c Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 17:41:13 +0100 Subject: Lint --- synapse/storage/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 23c4c31669..f60263502b 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,8 +19,8 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo -from ._base import SQLBaseStore from . import background_updates +from ._base import SQLBaseStore BATCH_SIZE = 100 -- cgit 1.5.1