From 111aee562b708a261b73f7aa5a5a17bf91396361 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 3 Sep 2020 17:12:13 +0100 Subject: [PATCH 1/4] Add delta file --- .../58/16populate_stats_process_rooms_fix.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 synapse/storage/databases/main/schema/delta/58/16populate_stats_process_rooms_fix.sql diff --git a/synapse/storage/databases/main/schema/delta/58/16populate_stats_process_rooms_fix.sql b/synapse/storage/databases/main/schema/delta/58/16populate_stats_process_rooms_fix.sql new file mode 100644 index 000000000000..55f5d0f7327c --- /dev/null +++ b/synapse/storage/databases/main/schema/delta/58/16populate_stats_process_rooms_fix.sql @@ -0,0 +1,22 @@ +/* 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. + */ +-- This delta file fixes a regression introduced by 58/12room_stats.sql, removing the hacky +-- populate_stats_process_rooms_2 background job and restores the functionality under the +-- original name. +-- See https://github.com/matrix-org/synapse/issues/8238 for details + +DELETE FROM background_updates WHERE update_name = 'populate_stats_process_rooms'; +UPDATE background_updates SET update_name = 'populate_stats_process_rooms' + WHERE update_name = 'populate_stats_process_rooms_2'; From 80275d260996b1894dbf8f23a9c67a1df0840495 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 3 Sep 2020 17:21:55 +0100 Subject: [PATCH 2/4] Remove *_2 method in the codebase --- synapse/storage/databases/main/stats.py | 29 +++++-------------------- tests/handlers/test_stats.py | 15 +++++-------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/synapse/storage/databases/main/stats.py b/synapse/storage/databases/main/stats.py index 55a250ef06fd..96d856051427 100644 --- a/synapse/storage/databases/main/stats.py +++ b/synapse/storage/databases/main/stats.py @@ -73,9 +73,6 @@ def __init__(self, database: DatabasePool, db_conn, hs): self.db_pool.updates.register_background_update_handler( "populate_stats_process_rooms", self._populate_stats_process_rooms ) - self.db_pool.updates.register_background_update_handler( - "populate_stats_process_rooms_2", self._populate_stats_process_rooms_2 - ) self.db_pool.updates.register_background_update_handler( "populate_stats_process_users", self._populate_stats_process_users ) @@ -148,22 +145,6 @@ def _get_next_batch(txn): return len(users_to_work_on) async def _populate_stats_process_rooms(self, progress, batch_size): - """ - This was a background update which regenerated statistics for rooms. - - It has been replaced by StatsStore._populate_stats_process_rooms_2. This background - job has been scheduled to run as part of Synapse v1.0.0, and again now. To ensure - someone upgrading from Date: Thu, 3 Sep 2020 17:27:44 +0100 Subject: [PATCH 3/4] Changelog --- changelog.d/8243.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8243.misc diff --git a/changelog.d/8243.misc b/changelog.d/8243.misc new file mode 100644 index 000000000000..f7375d32d33e --- /dev/null +++ b/changelog.d/8243.misc @@ -0,0 +1 @@ +Remove the 'populate_stats_process_rooms_2' background job and restore functionality to 'populate_stats_process_rooms'. \ No newline at end of file From a8a8122291602c9ce5359e197a25bab3364d4c56 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 3 Sep 2020 18:29:39 +0100 Subject: [PATCH 4/4] Remove replacement notice in docstring --- synapse/storage/databases/main/stats.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/synapse/storage/databases/main/stats.py b/synapse/storage/databases/main/stats.py index 96d856051427..30840dbbaa31 100644 --- a/synapse/storage/databases/main/stats.py +++ b/synapse/storage/databases/main/stats.py @@ -145,12 +145,7 @@ def _get_next_batch(txn): return len(users_to_work_on) async def _populate_stats_process_rooms(self, progress, batch_size): - """ - This is a background update which regenerates statistics for rooms. - - It replaces StatsStore._populate_stats_process_rooms. See its docstring for the - reasoning. - """ + """This is a background update which regenerates statistics for rooms.""" if not self.stats_enabled: await self.db_pool.updates._end_background_update( "populate_stats_process_rooms"