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

Commit 8aaa4b7

Browse files
authored
Drop backwards-compatibility support for "outlier" (#10903)
Before Synapse 1.31 (#9411), we relied on `outlier` being stored in the `internal_metadata` column. We can now assume nobody will roll back their deployment that far and drop the legacy support.
1 parent 2622b28 commit 8aaa4b7

File tree

3 files changed

+4
-25
lines changed

3 files changed

+4
-25
lines changed

changelog.d/10903.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop old functionality which maintained database compatibility with Synapse versions before 1.31.

synapse/storage/databases/main/events.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,6 @@ def _update_outliers_txn(self, txn, events_and_contexts):
12761276
logger.exception("")
12771277
raise
12781278

1279-
# update the stored internal_metadata to update the "outlier" flag.
1280-
# TODO: This is unused as of Synapse 1.31. Remove it once we are happy
1281-
# to drop backwards-compatibility with 1.30.
1282-
metadata_json = json_encoder.encode(event.internal_metadata.get_dict())
1283-
sql = "UPDATE event_json SET internal_metadata = ? WHERE event_id = ?"
1284-
txn.execute(sql, (metadata_json, event.event_id))
1285-
12861279
# Add an entry to the ex_outlier_stream table to replicate the
12871280
# change in outlier status to our workers.
12881281
stream_order = event.internal_metadata.stream_ordering
@@ -1327,19 +1320,6 @@ def event_dict(event):
13271320
d.pop("redacted_because", None)
13281321
return d
13291322

1330-
def get_internal_metadata(event):
1331-
im = event.internal_metadata.get_dict()
1332-
1333-
# temporary hack for database compatibility with Synapse 1.30 and earlier:
1334-
# store the `outlier` flag inside the internal_metadata json as well as in
1335-
# the `events` table, so that if anyone rolls back to an older Synapse,
1336-
# things keep working. This can be removed once we are happy to drop support
1337-
# for that
1338-
if event.internal_metadata.is_outlier():
1339-
im["outlier"] = True
1340-
1341-
return im
1342-
13431323
self.db_pool.simple_insert_many_txn(
13441324
txn,
13451325
table="event_json",
@@ -1348,7 +1328,7 @@ def get_internal_metadata(event):
13481328
"event_id": event.event_id,
13491329
"room_id": event.room_id,
13501330
"internal_metadata": json_encoder.encode(
1351-
get_internal_metadata(event)
1331+
event.internal_metadata.get_dict()
13521332
),
13531333
"json": json_encoder.encode(event_dict(event)),
13541334
"format_version": event.format_version,

synapse/storage/schema/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# When updating these values, please leave a short summary of the changes below.
16-
17-
SCHEMA_VERSION = 64
15+
SCHEMA_VERSION = 64 # remember to update the list below when updating
1816
"""Represents the expectations made by the codebase about the database schema
1917
2018
This should be incremented whenever the codebase changes its requirements on the
@@ -46,7 +44,7 @@
4644
"""
4745

4846

49-
SCHEMA_COMPAT_VERSION = 59
47+
SCHEMA_COMPAT_VERSION = 60 # 60: "outlier" not in internal_metadata.
5048
"""Limit on how far the synapse codebase can be rolled back without breaking db compat
5149
5250
This value is stored in the database, and checked on startup. If the value in the

0 commit comments

Comments
 (0)