From f8f71ea0ee7f98c47a89134bb7fe96fc4f25eea8 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 22 Mar 2020 16:30:52 +0100 Subject: [PATCH 1/8] Include method in thumbnail media name This fixes an issue where different methods (crop/scale) overwrite each other. Signed-off-by: Nicolas Werner --- synapse/rest/media/v1/filepath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/rest/media/v1/filepath.py b/synapse/rest/media/v1/filepath.py index e25c382c9c66..321e280faccf 100644 --- a/synapse/rest/media/v1/filepath.py +++ b/synapse/rest/media/v1/filepath.py @@ -80,7 +80,7 @@ def remote_media_thumbnail_rel( self, server_name, file_id, width, height, content_type, method ): top_level_type, sub_type = content_type.split("/") - file_name = "%i-%i-%s-%s" % (width, height, top_level_type, sub_type) + file_name = "%i-%i-%s-%s-%s" % (width, height, top_level_type, sub_type, method) return os.path.join( "remote_thumbnail", server_name, From dc2fa5d93fc6139b226a6d861d4d86af384bc9bb Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 22 Mar 2020 16:37:30 +0100 Subject: [PATCH 2/8] changelog Signed-off-by: Nicolas Werner --- changelog.d/7124.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7124.bugfix diff --git a/changelog.d/7124.bugfix b/changelog.d/7124.bugfix new file mode 100644 index 000000000000..47f8657a34a6 --- /dev/null +++ b/changelog.d/7124.bugfix @@ -0,0 +1 @@ +Fix a bug in the media repository where remote thumbnails with the same size but different crop methods would overwrite each other. From 3d72e607bf0ac2f13cceb7b979a9181974e2d63c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 10 Apr 2020 19:18:21 +0200 Subject: [PATCH 3/8] Add method to unique contraint on thumbnail tables Signed-off-by: Nicolas Werner --- ...ethod_to_thumbnail_constraint.sql.postgres | 21 ++++++++++ ..._method_to_thumbnail_constraint.sql.sqlite | 40 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres create mode 100644 synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite diff --git a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres new file mode 100644 index 000000000000..e39603ea4f4e --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres @@ -0,0 +1,21 @@ +/* Copyright 2020 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. + */ + +ALTER TABLE ONLY local_media_repository_thumbnails + DROP CONSTRAINT IF EXISTS local_media_repository_thumbn_media_id_thumbnail_width_thum_key, + ADD CONSTRAINT local_media_repository_thumbn_media_id_thumbnail_width_thum_key UNIQUE (media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method); +ALTER TABLE ONLY remote_media_cache_thumbnails + DROP CONSTRAINT IF EXISTS remote_media_cache_thumbnails_media_origin_media_id_thumbna_key, + ADD CONSTRAINT remote_media_cache_thumbnails_media_origin_media_id_thumbna_key UNIQUE (media_origin, media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method); diff --git a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite new file mode 100644 index 000000000000..15f8ee0ad8be --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite @@ -0,0 +1,40 @@ +/* Copyright 2020 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. + */ + +DROP INDEX IF EXISTS local_media_repository_thumbnails_media_id; + +CREATE TABLE local_media_repository_thumbnails_new ( media_id TEXT, thumbnail_width INTEGER, thumbnail_height INTEGER, thumbnail_type TEXT, thumbnail_method TEXT, thumbnail_length INTEGER, UNIQUE ( media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method ) ); + +INSERT INTO local_media_repository_thumbnails_new + SELECT media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method, thumbnail_length + FROM local_media_repository_thumbnails; + +DROP TABLE local_media_repository_thumbnails; + +ALTER TABLE local_media_repository_thumbnails_new RENAME TO local_media_repository_thumbnails; + +CREATE INDEX local_media_repository_thumbnails_media_id ON local_media_repository_thumbnails (media_id); + + + +CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails_new ( media_origin TEXT, media_id TEXT, thumbnail_width INTEGER, thumbnail_height INTEGER, thumbnail_method TEXT, thumbnail_type TEXT, thumbnail_length INTEGER, filesystem_id TEXT, UNIQUE ( media_origin, media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method ) ); + +INSERT INTO remote_media_cache_thumbnails_new + SELECT media_origin, media_id, thumbnail_width, thumbnail_height, thumbnail_method, thumbnail_type, thumbnail_length, filesystem_id + FROM remote_media_cache_thumbnails; + +DROP TABLE remote_media_cache_thumbnails; + +ALTER TABLE remote_media_cache_thumbnails_new RENAME TO remote_media_cache_thumbnails; From cfcd82d754d3c6c1949ce8174aa4d43995290725 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 10 May 2020 23:12:23 +0200 Subject: [PATCH 4/8] Do method for thumbnails migration in the background Signed-off-by: Nicolas Werner --- .../data_stores/main/media_repository.py | 71 +++++++++++++++++++ ...ethod_to_thumbnail_constraint.sql.postgres | 22 ++++-- 2 files changed, 87 insertions(+), 6 deletions(-) diff --git a/synapse/storage/data_stores/main/media_repository.py b/synapse/storage/data_stores/main/media_repository.py index 8aecd414c274..a4aa7ea3ac11 100644 --- a/synapse/storage/data_stores/main/media_repository.py +++ b/synapse/storage/data_stores/main/media_repository.py @@ -12,6 +12,8 @@ # 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. +from twisted.internet import defer + from synapse.storage._base import SQLBaseStore from synapse.storage.database import Database @@ -30,6 +32,75 @@ def __init__(self, database: Database, db_conn, hs): where_clause="url_cache IS NOT NULL", ) + self.db.updates.register_background_index_update( + update_name="local_media_repository_thumbnails_method_idx", + index_name="local_media_repository_thumbn_media_id_width_height_method_key", + table="local_media_repository_thumbnails", + columns=[ + "media_id", + "thumbnail_width", + "thumbnail_height", + "thumbnail_type", + "thumbnail_method", + ], + unique=True, + ) + + self.db.updates.register_background_index_update( + update_name="remote_media_repository_thumbnails_method_idx", + index_name="remote_media_repository_thumbn_media_origin_id_width_height_method_key", + table="remote_media_cache_thumbnails", + columns=[ + "media_origin", + "media_id", + "thumbnail_width", + "thumbnail_height", + "thumbnail_type", + "thumbnail_method", + ], + unique=True, + ) + + self.db.updates.register_background_update_handler( + "local_media_repository_drop_index_wo_method", + self._drop_local_media_index_without_method, + ) + + self.db.updates.register_background_update_handler( + "remote_media_repository_drop_index_wo_method", + self._drop_remote_media_index_without_method, + ) + + @defer.inlineCallbacks + def _drop_local_media_index_without_method(self, progress, batch_size): + def f(conn): + txn = conn.cursor() + txn.execute( + "ALTER TABLE local_media_repository_thumbnails DROP CONSTRAINT IF EXISTS local_media_repository_thumbn_media_id_thumbnail_width_thum_key" + ) + txn.close() + + yield self.db.runWithConnection(f) + yield self.db.updates._end_background_update( + "local_media_repository_drop_index_wo_method" + ) + return 1 + + @defer.inlineCallbacks + def _drop_remote_media_index_without_method(self, progress, batch_size): + def f(conn): + txn = conn.cursor() + txn.execute( + "ALTER TABLE remote_media_cache_thumbnails DROP CONSTRAINT IF EXISTS remote_media_repository_thumbn_media_id_thumbnail_width_thum_key" + ) + txn.close() + + yield self.db.runWithConnection(f) + yield self.db.updates._end_background_update( + "remote_media_repository_drop_index_wo_method" + ) + return 1 + class MediaRepositoryStore(MediaRepositoryBackgroundUpdateStore): """Persistence for attachments and avatars""" diff --git a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres index e39603ea4f4e..72c5c1a76cfe 100644 --- a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres +++ b/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres @@ -13,9 +13,19 @@ * limitations under the License. */ -ALTER TABLE ONLY local_media_repository_thumbnails - DROP CONSTRAINT IF EXISTS local_media_repository_thumbn_media_id_thumbnail_width_thum_key, - ADD CONSTRAINT local_media_repository_thumbn_media_id_thumbnail_width_thum_key UNIQUE (media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method); -ALTER TABLE ONLY remote_media_cache_thumbnails - DROP CONSTRAINT IF EXISTS remote_media_cache_thumbnails_media_origin_media_id_thumbna_key, - ADD CONSTRAINT remote_media_cache_thumbnails_media_origin_media_id_thumbna_key UNIQUE (media_origin, media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method); +-- add new index that includes method to local media +INSERT INTO background_updates (update_name, progress_json) VALUES + ('local_media_repository_thumbnails_method_idx', '{}'); + +-- drop old index +INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES + ('local_media_repository_drop_index_wo_method', '{}', 'local_media_repository_thumbnails_method_idx'); + +-- add new index that includes method to remote media +INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES + ('remote_media_repository_thumbnails_method_idx', '{}', 'local_media_repository_drop_index_wo_method'); + +-- drop old index +INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES + ('remote_media_repository_drop_index_wo_method', '{}', 'remote_media_repository_thumbnails_method_idx'); + From 5a682bab7145f4e7b46801a55c338e7701ab95e5 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 8 Jun 2020 17:08:31 +0200 Subject: [PATCH 5/8] Add fallback to old media path This first tries the new path. If that fails and we are looking for a remote thumbnail, it tries the old path. If that still isn't found, it continues as normal. This should probably be removed in the future, after some of the newer thumbnails were generated with the new path on most deployments. Then the overhead should be minimal if the other thumbnails need to be regenerated. Signed-off-by: Nicolas Werner --- synapse/rest/media/v1/filepath.py | 17 ++++++++++++++++ synapse/rest/media/v1/media_storage.py | 28 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/synapse/rest/media/v1/filepath.py b/synapse/rest/media/v1/filepath.py index 321e280faccf..fff3b664cd40 100644 --- a/synapse/rest/media/v1/filepath.py +++ b/synapse/rest/media/v1/filepath.py @@ -92,6 +92,23 @@ def remote_media_thumbnail_rel( remote_media_thumbnail = _wrap_in_base_path(remote_media_thumbnail_rel) + # Legacy path that was used to store thumbnails previously. + # Should be removed after some time, when most of the thumbnails are stored + # using the new path. + def remote_media_thumbnail_rel_legacy( + self, server_name, file_id, width, height, content_type + ): + top_level_type, sub_type = content_type.split("/") + file_name = "%i-%i-%s-%s" % (width, height, top_level_type, sub_type) + return os.path.join( + "remote_thumbnail", + server_name, + file_id[0:2], + file_id[2:4], + file_id[4:], + file_name, + ) + def remote_media_thumbnail_dir(self, server_name, file_id): return os.path.join( self.base_path, diff --git a/synapse/rest/media/v1/media_storage.py b/synapse/rest/media/v1/media_storage.py index 683a79c96641..172a29d7ed03 100644 --- a/synapse/rest/media/v1/media_storage.py +++ b/synapse/rest/media/v1/media_storage.py @@ -145,6 +145,20 @@ def fetch_media(self, file_info): if os.path.exists(local_path): return FileResponder(open(local_path, "rb")) + # Fallback for paths without method names + # Should be removed in the future + if file_info.thumbnail and file_info.server_name: + legacy_path = self.filepaths.remote_media_thumbnail_rel_legacy( + server_name=file_info.server_name, + file_id=file_info.file_id, + width=file_info.thumbnail_width, + height=file_info.thumbnail_height, + content_type=file_info.thumbnail_type, + ) + legacy_local_path = os.path.join(self.local_media_directory, legacy_path) + if os.path.exists(legacy_local_path): + return FileResponder(open(legacy_local_path, "rb")) + for provider in self.storage_providers: res = yield provider.fetch(path, file_info) if res: @@ -169,6 +183,20 @@ def ensure_media_is_in_local_cache(self, file_info): if os.path.exists(local_path): return local_path + # Fallback for paths without method names + # Should be removed in the future + if file_info.thumbnail and file_info.server_name: + legacy_path = self.filepaths.remote_media_thumbnail_rel_legacy( + server_name=file_info.server_name, + file_id=file_info.file_id, + width=file_info.thumbnail_width, + height=file_info.thumbnail_height, + content_type=file_info.thumbnail_type, + ) + legacy_local_path = os.path.join(self.local_media_directory, legacy_path) + if os.path.exists(legacy_local_path): + return legacy_local_path + dirname = os.path.dirname(local_path) if not os.path.exists(dirname): os.makedirs(dirname) From f8870f3b93f89269b5c7dff22adce4d1e684475c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 31 Aug 2020 15:18:37 +0200 Subject: [PATCH 6/8] Address review comments --- .../data_stores/main/media_repository.py | 44 +++++++------------ ...thod_to_thumbnail_constraint.sql.postgres} | 20 +++++---- ...method_to_thumbnail_constraint.sql.sqlite} | 12 +++-- 3 files changed, 34 insertions(+), 42 deletions(-) rename synapse/storage/data_stores/main/schema/delta/58/{add_method_to_thumbnail_constraint.sql.postgres => 07add_method_to_thumbnail_constraint.sql.postgres} (67%) rename synapse/storage/data_stores/main/schema/delta/58/{add_method_to_thumbnail_constraint.sql.sqlite => 07add_method_to_thumbnail_constraint.sql.sqlite} (82%) diff --git a/synapse/storage/data_stores/main/media_repository.py b/synapse/storage/data_stores/main/media_repository.py index a4aa7ea3ac11..9e3d53034dfb 100644 --- a/synapse/storage/data_stores/main/media_repository.py +++ b/synapse/storage/data_stores/main/media_repository.py @@ -12,11 +12,13 @@ # 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. -from twisted.internet import defer - from synapse.storage._base import SQLBaseStore from synapse.storage.database import Database +BG_UPDATE_REMOVE_MEDIA_REPO_INDEX_WITHOUT_METHOD = ( + "media_repository_drop_index_wo_method" +) + class MediaRepositoryBackgroundUpdateStore(SQLBaseStore): def __init__(self, database: Database, db_conn, hs): @@ -32,6 +34,10 @@ def __init__(self, database: Database, db_conn, hs): where_clause="url_cache IS NOT NULL", ) + # The following the updates add the method to the unique constraint of + # the thumbnail databases. That fixes an issue, where thumbnails of the + # same resolution, but different methods could overwrite one another. + # This can happen with custom thumbnail configs or with dynamic thumbnailing. self.db.updates.register_background_index_update( update_name="local_media_repository_thumbnails_method_idx", index_name="local_media_repository_thumbn_media_id_width_height_method_key", @@ -62,42 +68,22 @@ def __init__(self, database: Database, db_conn, hs): ) self.db.updates.register_background_update_handler( - "local_media_repository_drop_index_wo_method", - self._drop_local_media_index_without_method, - ) - - self.db.updates.register_background_update_handler( - "remote_media_repository_drop_index_wo_method", - self._drop_remote_media_index_without_method, + BG_UPDATE_REMOVE_MEDIA_REPO_INDEX_WITHOUT_METHOD, + self._drop_media_index_without_method, ) - @defer.inlineCallbacks - def _drop_local_media_index_without_method(self, progress, batch_size): - def f(conn): - txn = conn.cursor() + async def _drop_media_index_without_method(self, progress, batch_size): + def f(txn): txn.execute( "ALTER TABLE local_media_repository_thumbnails DROP CONSTRAINT IF EXISTS local_media_repository_thumbn_media_id_thumbnail_width_thum_key" ) - txn.close() - - yield self.db.runWithConnection(f) - yield self.db.updates._end_background_update( - "local_media_repository_drop_index_wo_method" - ) - return 1 - - @defer.inlineCallbacks - def _drop_remote_media_index_without_method(self, progress, batch_size): - def f(conn): - txn = conn.cursor() txn.execute( "ALTER TABLE remote_media_cache_thumbnails DROP CONSTRAINT IF EXISTS remote_media_repository_thumbn_media_id_thumbnail_width_thum_key" ) - txn.close() - yield self.db.runWithConnection(f) - yield self.db.updates._end_background_update( - "remote_media_repository_drop_index_wo_method" + await self.db.runInteraction(f) + await self.db.updates._end_background_update( + BG_UPDATE_REMOVE_MEDIA_REPO_INDEX_WITHOUT_METHOD ) return 1 diff --git a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres b/synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.postgres similarity index 67% rename from synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres rename to synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.postgres index 72c5c1a76cfe..b64926e9c9eb 100644 --- a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.postgres +++ b/synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.postgres @@ -1,6 +1,4 @@ -/* Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); +/* 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 * @@ -13,19 +11,23 @@ * limitations under the License. */ +/* + * This adds the method to the unique key constraint of the thumbnail databases. + * Otherwise you can't have a scaled and a cropped thumbnail with the same + * resolution, which happens quite often with dynamic thumbnailing. + * This is the postgres specific migration modifying the table with a background + * migration. + */ + -- add new index that includes method to local media INSERT INTO background_updates (update_name, progress_json) VALUES ('local_media_repository_thumbnails_method_idx', '{}'); --- drop old index -INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES - ('local_media_repository_drop_index_wo_method', '{}', 'local_media_repository_thumbnails_method_idx'); - -- add new index that includes method to remote media INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES - ('remote_media_repository_thumbnails_method_idx', '{}', 'local_media_repository_drop_index_wo_method'); + ('remote_media_repository_thumbnails_method_idx', '{}', 'local_media_repository_thumbnails_method_idx'); -- drop old index INSERT INTO background_updates (update_name, progress_json, depends_on) VALUES - ('remote_media_repository_drop_index_wo_method', '{}', 'remote_media_repository_thumbnails_method_idx'); + ('media_repository_drop_index_wo_method', '{}', 'remote_media_repository_thumbnails_method_idx'); diff --git a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite b/synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.sqlite similarity index 82% rename from synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite rename to synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.sqlite index 15f8ee0ad8be..1d0c04b53a8c 100644 --- a/synapse/storage/data_stores/main/schema/delta/58/add_method_to_thumbnail_constraint.sql.sqlite +++ b/synapse/storage/data_stores/main/schema/delta/58/07add_method_to_thumbnail_constraint.sql.sqlite @@ -1,6 +1,4 @@ -/* Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); +/* 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 * @@ -13,7 +11,13 @@ * limitations under the License. */ -DROP INDEX IF EXISTS local_media_repository_thumbnails_media_id; +/* + * This adds the method to the unique key constraint of the thumbnail databases. + * Otherwise you can't have a scaled and a cropped thumbnail with the same + * resolution, which happens quite often with dynamic thumbnailing. + * This is a sqlite specific migration, since sqlite can't modify the unique + * constraint of a table without recreating it. + */ CREATE TABLE local_media_repository_thumbnails_new ( media_id TEXT, thumbnail_width INTEGER, thumbnail_height INTEGER, thumbnail_type TEXT, thumbnail_method TEXT, thumbnail_length INTEGER, UNIQUE ( media_id, thumbnail_width, thumbnail_height, thumbnail_type, thumbnail_method ) ); From 32b7fb524f51802c0851a70fcab96f14ad82621f Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 31 Aug 2020 16:05:31 +0200 Subject: [PATCH 7/8] Add function name parameter missed in move to runInteraction --- synapse/storage/databases/main/media_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index 8b27953042d6..e6428a25beef 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -83,7 +83,7 @@ def f(txn): "ALTER TABLE remote_media_cache_thumbnails DROP CONSTRAINT IF EXISTS remote_media_repository_thumbn_media_id_thumbnail_width_thum_key" ) - await self.db_pool.runInteraction(f) + await self.db_pool.runInteraction("drop_media_indices_without_method", f) await self.db_pool.updates._end_background_update( BG_UPDATE_REMOVE_MEDIA_REPO_INDEX_WITHOUT_METHOD ) From b494542dea192630ea750e39223cfb3bc7326708 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 8 Sep 2020 17:19:10 +0100 Subject: [PATCH 8/8] Update changelog.d/7124.bugfix --- changelog.d/7124.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/7124.bugfix b/changelog.d/7124.bugfix index 47f8657a34a6..8fd177780d7d 100644 --- a/changelog.d/7124.bugfix +++ b/changelog.d/7124.bugfix @@ -1 +1 @@ -Fix a bug in the media repository where remote thumbnails with the same size but different crop methods would overwrite each other. +Fix a bug in the media repository where remote thumbnails with the same size but different crop methods would overwrite each other. Contributed by @deepbluev7.