Skip to content

Commit 72ca424

Browse files
committed
Merge branch 'develop' into madlittlemods/shutdown-homeserver-that-was-never-setup
2 parents b3aab27 + ba65d8c commit 72ca424

20 files changed

Lines changed: 371 additions & 19 deletions

File tree

CHANGES.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
# Synapse 1.143.0rc2 (2025-11-18)
1+
# Synapse 1.143.0 (2025-11-25)
22

3-
## Internal Changes
3+
## Dropping support for PostgreSQL 13
44

5-
- Fixes docker image creation in the release workflow.
5+
In line with our [deprecation policy](https://github.com/element-hq/synapse/blob/develop/docs/deprecation_policy.md), we've dropped
6+
support for PostgreSQL 13, as it is no longer supported upstream.
7+
This release of Synapse requires PostgreSQL 14+.
68

9+
No significant changes since 1.143.0rc2.
710

811

9-
# Synapse 1.143.0rc1 (2025-11-18)
12+
13+
14+
# Synapse 1.143.0rc2 (2025-11-18)
1015

1116
## Dropping support for PostgreSQL 13
1217

1318
In line with our [deprecation policy](https://github.com/element-hq/synapse/blob/develop/docs/deprecation_policy.md), we've dropped
1419
support for PostgreSQL 13, as it is no longer supported upstream.
1520
This release of Synapse requires PostgreSQL 14+.
1621

22+
23+
## Internal Changes
24+
25+
- Fixes docker image creation in the release workflow.
26+
27+
28+
29+
# Synapse 1.143.0rc1 (2025-11-18)
30+
1731
## Features
1832

1933
- Support multiple config files in `register_new_matrix_user`. ([\#18784](https://github.com/element-hq/synapse/issues/18784))

changelog.d/19211.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expire sliding sync connections that are too old or have too much pending data.

changelog.d/19219.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Require an experimental feature flag to be enabled in order for the unstable [MSC2666](https://github.com/matrix-org/matrix-spec-proposals/pull/2666) endpoint (`/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms`) to be available.

changelog.d/19221.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Auto-fix trailing spaces in multi-line strings and comments when running the lint script.

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
matrix-synapse-py3 (1.143.0) stable; urgency=medium
2+
3+
* New Synapse release 1.143.0.
4+
5+
-- Synapse Packaging team <packages@matrix.org> Tue, 25 Nov 2025 08:44:56 -0700
6+
17
matrix-synapse-py3 (1.143.0~rc2) stable; urgency=medium
28

39
* New Synapse release 1.143.0rc2.

docs/upgrade.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ each upgrade are complete before moving on to the next upgrade, to avoid
117117
stacking them up. You can monitor the currently running background updates with
118118
[the Admin API](usage/administration/admin_api/background_updates.html#status).
119119
120+
# Upgrading to v1.144.0
121+
122+
## Unstable mutual rooms endpoint is now behind an experimental feature flag
123+
124+
The unstable mutual rooms endpoint from
125+
[MSC2666](https://github.com/matrix-org/matrix-spec-proposals/pull/2666)
126+
(`/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms`) is now
127+
disabled by default. If you rely on this unstable endpoint, you must now set
128+
`experimental_features.msc2666_enabled: true` in your configuration to keep
129+
using it.
130+
120131
# Upgrading to v1.143.0
121132
122133
## Dropping support for PostgreSQL 13

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "matrix-synapse"
3-
version = "1.143.0rc2"
3+
version = "1.143.0"
44
description = "Homeserver for the Matrix decentralised comms protocol"
55
readme = "README.rst"
66
authors = [
@@ -269,6 +269,8 @@ extend-safe-fixes = [
269269
"UP007",
270270
# pyupgrade rules compatible with Python >= 3.10
271271
"UP045",
272+
# Allow ruff to automatically fix trailing spaces within a multi-line string/comment.
273+
"W293"
272274
]
273275

274276
[tool.ruff.lint.isort]

synapse/config/experimental.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ def read_config(
438438
# previously calculated push actions.
439439
self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False)
440440

441+
# MSC2666: Query mutual rooms between two users.
442+
self.msc2666_enabled: bool = experimental.get("msc2666_enabled", False)
443+
441444
# MSC2815 (allow room moderators to view redacted event content)
442445
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
443446

synapse/handlers/sliding_sync/room_lists.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
EventTypes,
3535
Membership,
3636
)
37+
from synapse.api.errors import SlidingSyncUnknownPosition
3738
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
3839
from synapse.events import StrippedStateEvent
3940
from synapse.events.utils import parse_stripped_state_event
4041
from synapse.logging.opentracing import start_active_span, trace
42+
from synapse.storage.databases.main.sliding_sync import UPDATE_INTERVAL_LAST_USED_TS_MS
4143
from synapse.storage.databases.main.state import (
4244
ROOM_UNKNOWN_SENTINEL,
4345
Sentinel as StateSentinel,
@@ -68,6 +70,7 @@
6870
)
6971
from synapse.types.state import StateFilter
7072
from synapse.util import MutableOverlayMapping
73+
from synapse.util.constants import MILLISECONDS_PER_SECOND, ONE_HOUR_SECONDS
7174
from synapse.util.sentinel import Sentinel
7275

7376
if TYPE_CHECKING:
@@ -77,6 +80,27 @@
7780
logger = logging.getLogger(__name__)
7881

7982

83+
# Minimum time in milliseconds since the last sync before we consider expiring
84+
# the connection due to too many rooms to send. This stops from getting into
85+
# tight loops with clients that request lots of data at once.
86+
#
87+
# c.f. `NUM_ROOMS_THRESHOLD`. These values are somewhat arbitrary picked.
88+
MINIMUM_NOT_USED_AGE_EXPIRY_MS = ONE_HOUR_SECONDS * MILLISECONDS_PER_SECOND
89+
90+
# How many rooms with updates we allow before we consider the connection expired
91+
# due to too many rooms to send.
92+
#
93+
# c.f. `MINIMUM_NOT_USED_AGE_EXPIRY_MS`. These values are somewhat arbitrary
94+
# picked.
95+
NUM_ROOMS_THRESHOLD = 100
96+
97+
# Sanity check that our minimum age is sensible compared to the update interval,
98+
# i.e. if `MINIMUM_NOT_USED_AGE_EXPIRY_MS` is too small then we might expire the
99+
# connection even if it is actively being used (and we're just not updating the
100+
# DB frequently enough). We arbitrarily double the update interval to give some
101+
# wiggle room.
102+
assert 2 * UPDATE_INTERVAL_LAST_USED_TS_MS < MINIMUM_NOT_USED_AGE_EXPIRY_MS
103+
80104
# Helper definition for the types that we might return. We do this to avoid
81105
# copying data between types (which can be expensive for many rooms).
82106
RoomsForUserType = RoomsForUserStateReset | RoomsForUser | RoomsForUserSlidingSync
@@ -176,6 +200,7 @@ def __init__(self, hs: "HomeServer"):
176200
self.storage_controllers = hs.get_storage_controllers()
177201
self.rooms_to_exclude_globally = hs.config.server.rooms_to_exclude_from_sync
178202
self.is_mine_id = hs.is_mine_id
203+
self._clock = hs.get_clock()
179204

180205
async def compute_interested_rooms(
181206
self,
@@ -857,11 +882,41 @@ async def _filter_relevant_rooms_to_send(
857882

858883
# We only need to check for new events since any state changes
859884
# will also come down as new events.
860-
rooms_that_have_updates = (
861-
self.store.get_rooms_that_might_have_updates(
885+
886+
rooms_that_have_updates = await (
887+
self.store.get_rooms_that_have_updates_since_sliding_sync_table(
862888
relevant_room_map.keys(), from_token.room_key
863889
)
864890
)
891+
892+
# Check if we have lots of updates to send, if so then its
893+
# better for us to tell the client to do a full resync
894+
# instead (to try and avoid long SSS response times when
895+
# there is new data).
896+
#
897+
# Due to the construction of the SSS API, the client is in
898+
# charge of setting the range of rooms to request updates
899+
# for. Generally, it will start with a small range and then
900+
# expand (and occasionally it may contract the range again
901+
# if its been offline for a while). If we know there are a
902+
# lot of updates, it's better to reset the connection and
903+
# wait for the client to start again (with a much smaller
904+
# range) than to try and send down a large number of updates
905+
# (which can take a long time).
906+
#
907+
# We only do this if the last sync was over
908+
# `MINIMUM_NOT_USED_AGE_EXPIRY_MS` to ensure we don't get
909+
# into tight loops with clients that keep requesting large
910+
# sliding sync windows.
911+
if len(rooms_that_have_updates) > NUM_ROOMS_THRESHOLD:
912+
last_sync_ts = previous_connection_state.last_used_ts
913+
if (
914+
last_sync_ts is not None
915+
and (self._clock.time_msec() - last_sync_ts)
916+
> MINIMUM_NOT_USED_AGE_EXPIRY_MS
917+
):
918+
raise SlidingSyncUnknownPosition()
919+
865920
rooms_should_send.update(rooms_that_have_updates)
866921
relevant_rooms_to_send_map = {
867922
room_id: room_sync_config

synapse/handlers/sliding_sync/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def get_and_clear_connection_positions(
7575
"""
7676
# If this is our first request, there is no previous connection state to fetch out of the database
7777
if from_token is None or from_token.connection_position == 0:
78-
return PerConnectionState()
78+
return PerConnectionState(last_used_ts=None)
7979

8080
conn_id = sync_config.conn_id or ""
8181

0 commit comments

Comments
 (0)