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

Commit e26d7d5

Browse files
author
David Robertson
authored
Teach portdb about un_partial_stated_event_stream (#15108)
* Sort BOOLEAN_COLUMNS and APPEND_ONLY_TABLES So I can see if a given table is present in logarithmic time, rather than linear. * Teach portdb about `un_partial_stated_event_streams` * Comments comments comments * Changelog
1 parent 490a367 commit e26d7d5

File tree

2 files changed

+53
-33
lines changed

2 files changed

+53
-33
lines changed

changelog.d/15108.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug introduced in Synapse 1.75 where the [portdb script](https://matrix-org.github.io/synapse/release-v1.78/postgres.html#porting-from-sqlite) would fail to run after a room had been faster-joined.

synapse/_scripts/synapse_port_db.py

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -94,61 +94,80 @@
9494
logger = logging.getLogger("synapse_port_db")
9595

9696

97+
# SQLite doesn't have a dedicated boolean type (it stores True/False as 1/0). This means
98+
# portdb will read sqlite bools as integers, then try to insert them into postgres
99+
# boolean columns---which fails. Lacking some Python-parseable metaschema, we must
100+
# specify which integer columns should be inserted as booleans into postgres.
97101
BOOLEAN_COLUMNS = {
98-
"events": ["processed", "outlier", "contains_url"],
99-
"rooms": ["is_public", "has_auth_chain_index"],
102+
"access_tokens": ["used"],
103+
"account_validity": ["email_sent"],
104+
"device_lists_changes_in_room": ["converted_to_destinations"],
105+
"device_lists_outbound_pokes": ["sent"],
106+
"devices": ["hidden"],
107+
"e2e_fallback_keys_json": ["used"],
108+
"e2e_room_keys": ["is_verified"],
100109
"event_edges": ["is_state"],
110+
"events": ["processed", "outlier", "contains_url"],
111+
"local_media_repository": ["safe_from_quarantine"],
101112
"presence_list": ["accepted"],
102113
"presence_stream": ["currently_active"],
103114
"public_room_list_stream": ["visibility"],
104-
"devices": ["hidden"],
105-
"device_lists_outbound_pokes": ["sent"],
106-
"users_who_share_rooms": ["share_private"],
107-
"e2e_room_keys": ["is_verified"],
108-
"account_validity": ["email_sent"],
115+
"pushers": ["enabled"],
109116
"redactions": ["have_censored"],
110117
"room_stats_state": ["is_federatable"],
111-
"local_media_repository": ["safe_from_quarantine"],
118+
"rooms": ["is_public", "has_auth_chain_index"],
112119
"users": ["shadow_banned", "approved"],
113-
"e2e_fallback_keys_json": ["used"],
114-
"access_tokens": ["used"],
115-
"device_lists_changes_in_room": ["converted_to_destinations"],
116-
"pushers": ["enabled"],
120+
"un_partial_stated_event_stream": ["rejection_status_changed"],
121+
"users_who_share_rooms": ["share_private"],
117122
}
118123

119124

125+
# These tables are never deleted from in normal operation [*], so we can resume porting
126+
# over rows from a previous attempt rather than starting from scratch.
127+
#
128+
# [*]: We do delete from many of these tables when purging a room, and
129+
# presumably when purging old events. So we might e.g.
130+
#
131+
# 1. Run portdb and port half of some table.
132+
# 2. Stop portdb.
133+
# 3. Purge something, deleting some of the rows we've ported over.
134+
# 4. Restart portdb. The rows deleted from sqlite are still present in postgres.
135+
#
136+
# But this isn't the end of the world: we should be able to repeat the purge
137+
# on the postgres DB when porting completes.
120138
APPEND_ONLY_TABLES = [
139+
"cache_invalidation_stream_by_instance",
140+
"event_auth",
141+
"event_edges",
142+
"event_json",
121143
"event_reference_hashes",
144+
"event_search",
145+
"event_to_state_groups",
122146
"events",
123-
"event_json",
124-
"state_events",
125-
"room_memberships",
126-
"topics",
127-
"room_names",
128-
"rooms",
147+
"ex_outlier_stream",
129148
"local_media_repository",
130149
"local_media_repository_thumbnails",
150+
"presence_stream",
151+
"public_room_list_stream",
152+
"push_rules_stream",
153+
"received_transactions",
154+
"redactions",
155+
"rejections",
131156
"remote_media_cache",
132157
"remote_media_cache_thumbnails",
133-
"redactions",
134-
"event_edges",
135-
"event_auth",
136-
"received_transactions",
158+
"room_memberships",
159+
"room_names",
160+
"rooms",
137161
"sent_transactions",
138-
"transaction_id_to_pdu",
139-
"users",
162+
"state_events",
163+
"state_group_edges",
140164
"state_groups",
141165
"state_groups_state",
142-
"event_to_state_groups",
143-
"rejections",
144-
"event_search",
145-
"presence_stream",
146-
"push_rules_stream",
147-
"ex_outlier_stream",
148-
"cache_invalidation_stream_by_instance",
149-
"public_room_list_stream",
150-
"state_group_edges",
151166
"stream_ordering_to_exterm",
167+
"topics",
168+
"transaction_id_to_pdu",
169+
"un_partial_stated_event_stream",
170+
"users",
152171
]
153172

154173

0 commit comments

Comments
 (0)