summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-06-13 18:10:14 +0100
committerGitHub <noreply@github.com>2019-06-13 18:10:14 +0100
commita6cf1e079e490cb67e43b82a7e1909e1208be9b2 (patch)
tree2bbd3cfcce476a0a0c43f6c5ca3f3545b63551b2
parentRegenerate full schemas (diff)
parentLint (diff)
downloadsynapse-a6cf1e079e490cb67e43b82a7e1909e1208be9b2.tar.xz
Merge pull request #5416 from matrix-org/babolivier/fix_profile_replication
Add unique index to the profile_replication_status table.
-rw-r--r--changelog.d/5083.feature2
-rw-r--r--changelog.d/5416.misc1
-rw-r--r--synapse/rest/client/v1/profile.py1
-rw-r--r--synapse/storage/profile.py14
-rw-r--r--synapse/storage/schema/delta/55/profile_replication_status_index.sql17
5 files changed, 32 insertions, 3 deletions
diff --git a/changelog.d/5083.feature b/changelog.d/5083.feature
index f6014c6b43..2ffdd37eef 100644
--- a/changelog.d/5083.feature
+++ b/changelog.d/5083.feature
@@ -1 +1 @@
-Adds auth_profile_reqs option to require access_token to GET /profile endpoints on CS API
+Adds auth_profile_reqs option to require access_token to GET /profile endpoints on CS API.
diff --git a/changelog.d/5416.misc b/changelog.d/5416.misc
new file mode 100644
index 0000000000..155e8c7cd3
--- /dev/null
+++ b/changelog.d/5416.misc
@@ -0,0 +1 @@
+Add unique index to the profile_replication_status table.
diff --git a/synapse/rest/client/v1/profile.py b/synapse/rest/client/v1/profile.py
index 202a9f21ad..064bcddaeb 100644
--- a/synapse/rest/client/v1/profile.py
+++ b/synapse/rest/client/v1/profile.py
@@ -22,7 +22,6 @@ from synapse.http.servlet import RestServlet, parse_json_object_from_request
 from synapse.rest.client.v2_alpha._base import client_patterns
 from synapse.types import UserID
 
-
 logger = logging.getLogger(__name__)
 
 
diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py
index 04908cbc35..f60263502b 100644
--- a/synapse/storage/profile.py
+++ b/synapse/storage/profile.py
@@ -19,6 +19,7 @@ from twisted.internet import defer
 from synapse.api.errors import StoreError
 from synapse.storage.roommember import ProfileInfo
 
+from . import background_updates
 from ._base import SQLBaseStore
 
 BATCH_SIZE = 100
@@ -165,7 +166,18 @@ class ProfileWorkerStore(SQLBaseStore):
         )
 
 
-class ProfileStore(ProfileWorkerStore):
+class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore):
+    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.
 
diff --git a/synapse/storage/schema/delta/55/profile_replication_status_index.sql b/synapse/storage/schema/delta/55/profile_replication_status_index.sql
new file mode 100644
index 0000000000..18a0f7e10c
--- /dev/null
+++ b/synapse/storage/schema/delta/55/profile_replication_status_index.sql
@@ -0,0 +1,17 @@
+/* Copyright 2019 New Vector Ltd
+ *
+ * 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.
+ */
+
+INSERT INTO background_updates (update_name, progress_json) VALUES
+  ('profile_replication_status_host_index', '{}');