Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit c369e95

Browse files
authored
Rebuild the user directory and stats tables. (#14643)
Due to the various fixes to the StreamChangeCache it is not safe to trust the information in the user directory or room/user stats tables. Rebuild them as background jobs. In particular see da77720 (#14639), and 6a8310f (#14435). Maybe also be related to fac8a38 (#14592).
1 parent 9d8a323 commit c369e95

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

changelog.d/14643.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where the user directory and room/user stats might be out of sync.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright 2022 The Matrix.org Foundation C.I.C
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
INSERT INTO background_updates (ordering, update_name, progress_json, depends_on) VALUES
17+
-- Set up user directory staging tables.
18+
(7322, 'populate_user_directory_createtables', '{}', NULL),
19+
-- Run through each room and update the user directory according to who is in it.
20+
(7322, 'populate_user_directory_process_rooms', '{}', 'populate_user_directory_createtables'),
21+
-- Insert all users into the user directory, if search_all_users is on.
22+
(7322, 'populate_user_directory_process_users', '{}', 'populate_user_directory_process_rooms'),
23+
-- Clean up user directory staging tables.
24+
(7322, 'populate_user_directory_cleanup', '{}', 'populate_user_directory_process_users'),
25+
-- Rebuild the room_stats_current and room_stats_state tables.
26+
(7322, 'populate_stats_process_rooms', '{}', NULL),
27+
-- Update the user_stats_current table.
28+
(7322, 'populate_stats_process_users', '{}', NULL)
29+
ON CONFLICT (update_name) DO NOTHING;

0 commit comments

Comments
 (0)