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

Commit

Permalink
Merge tag 'v1.83.0' into merge-1.83
Browse files Browse the repository at this point in the history
Synapse 1.83.0 (2023-05-09)
===========================

No significant changes since 1.83.0rc1.

Synapse 1.83.0rc1 (2023-05-02)
==============================

Features
--------

- Experimental support to recursively provide relations per [MSC3981](matrix-org/matrix-spec-proposals#3981). ([\matrix-org#15315](matrix-org#15315))
- Experimental support for [MSC3970](matrix-org/matrix-spec-proposals#3970): Scope transaction IDs to devices. ([\matrix-org#15318](matrix-org#15318))
- Add an [admin API endpoint](https://matrix-org.github.io/synapse/v1.83/admin_api/experimental_features.html) to support per-user feature flags. ([\matrix-org#15344](matrix-org#15344))
- Add a module API to send an HTTP push notification. ([\matrix-org#15387](matrix-org#15387))
- Add an [admin API endpoint](https://matrix-org.github.io/synapse/v1.83/admin_api/statistics.html#get-largest-rooms-by-size-in-database) to query the largest rooms by disk space used in the database. ([\matrix-org#15482](matrix-org#15482))

Bugfixes
--------

- Disable push rule evaluation for rooms excluded from sync. ([\matrix-org#15361](matrix-org#15361))
- Fix a long-standing bug where cached server key results which were directly fetched would not be properly re-used. ([\matrix-org#15417](matrix-org#15417))
- Fix a bug introduced in Synapse 1.73.0 where some experimental push rules were returned by default. ([\matrix-org#15494](matrix-org#15494))

Improved Documentation
----------------------

- Add Nginx loadbalancing example with sticky mxid for workers. ([\matrix-org#15411](matrix-org#15411))
- Update outdated development docs that mention restrictions in versions of SQLite that we no longer support. ([\matrix-org#15498](matrix-org#15498))

Internal Changes
----------------

- Speedup tests by caching HomeServerConfig instances. ([\matrix-org#15284](matrix-org#15284))
- Add denormalised event stream ordering column to membership state tables for future use. Contributed by Nick @ Beeper (@Fizzadar). ([\matrix-org#15356](matrix-org#15356))
- Always use multi-user device resync replication endpoints. ([\matrix-org#15418](matrix-org#15418))
- Add column `full_user_id` to tables `profiles` and `user_filters`. ([\matrix-org#15458](matrix-org#15458))
- Update support for [MSC3983](matrix-org/matrix-spec-proposals#3983) to allow always returning fallback-keys in a `/keys/claim` request. ([\matrix-org#15462](matrix-org#15462))
- Improve type hints. ([\matrix-org#15465](matrix-org#15465), [\matrix-org#15496](matrix-org#15496), [\matrix-org#15497](matrix-org#15497))
- Support claiming more than one OTK at a time. ([\matrix-org#15468](matrix-org#15468))
- Bump types-pyyaml from 6.0.12.8 to 6.0.12.9. ([\matrix-org#15471](matrix-org#15471))
- Bump pyasn1-modules from 0.2.8 to 0.3.0. ([\matrix-org#15473](matrix-org#15473))
- Bump cryptography from 40.0.1 to 40.0.2. ([\matrix-org#15474](matrix-org#15474))
- Bump types-netaddr from 0.8.0.7 to 0.8.0.8. ([\matrix-org#15475](matrix-org#15475))
- Bump types-jsonschema from 4.17.0.6 to 4.17.0.7. ([\matrix-org#15476](matrix-org#15476))
- Ask bug reporters to provide logs as text. ([\matrix-org#15479](matrix-org#15479))
- Add a Nix flake for use as a development environment. ([\matrix-org#15495](matrix-org#15495))
- Bump anyhow from 1.0.70 to 1.0.71. ([\matrix-org#15507](matrix-org#15507))
- Bump types-pillow from 9.4.0.19 to 9.5.0.2. ([\matrix-org#15508](matrix-org#15508))
- Bump packaging from 23.0 to 23.1. ([\matrix-org#15510](matrix-org#15510))
- Bump types-requests from 2.28.11.16 to 2.29.0.0. ([\matrix-org#15511](matrix-org#15511))
- Bump setuptools-rust from 1.5.2 to 1.6.0. ([\matrix-org#15512](matrix-org#15512))
- Update the check_schema_delta script to account for when the schema version has been bumped locally. ([\matrix-org#15466](matrix-org#15466))

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYIAB0WIQSTI7xPaHQ1yo0PA8uSL1esuTqr+QUCZFp2zQAKCRCSL1esuTqr
# +YVzAP94u5kth80qhAB5x/vpCMrpPZC8Hk4kPTNwTuqCia7qGQEAlcEgsNXRmLnw
# esBnwhQE+ntwodK4uvHKjVZafkDG2gs=
# =N1Pk
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue May  9 17:37:33 2023 BST
# gpg:                using EDDSA key 9323BC4F687435CA8D0F03CB922F57ACB93AABF9
# gpg: Can't check signature: No public key

# Conflicts:
#	poetry.lock
#	synapse/events/utils.py
#	synapse/push/bulk_push_rule_evaluator.py
#	synapse/push/httppusher.py
#	synapse/server.py
  • Loading branch information
Fizzadar committed May 18, 2023
2 parents b4b6ef6 + 64a11fb commit 06806f4
Show file tree
Hide file tree
Showing 119 changed files with 3,331 additions and 820 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Expand Up @@ -129,7 +129,7 @@ body:
attributes:
label: Relevant log output
description: |
Please copy and paste any relevant log output, ideally at INFO or DEBUG log level.
Please copy and paste any relevant log output as text (not images), ideally at INFO or DEBUG log level.
This will be automatically formatted into code, so there is no need for backticks (`\``).
Please be careful to remove any personal or private data.
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -15,9 +15,10 @@ _trial_temp*/
.DS_Store
__pycache__/

# We do want the poetry and cargo lockfile.
# We do want poetry, cargo and flake lockfiles.
!poetry.lock
!Cargo.lock
!flake.lock

# stuff that is likely to exist when you run a server locally
/*.db
Expand All @@ -38,6 +39,9 @@ __pycache__/
/.envrc
.direnv/

# For nix/devenv users
.devenv/

# IDEs
/.idea/
/.ropeproject/
Expand Down
59 changes: 59 additions & 0 deletions CHANGES.md
@@ -1,3 +1,62 @@
Synapse 1.83.0 (2023-05-09)
===========================

No significant changes since 1.83.0rc1.


Synapse 1.83.0rc1 (2023-05-02)
==============================

Features
--------

- Experimental support to recursively provide relations per [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981). ([\#15315](https://github.com/matrix-org/synapse/issues/15315))
- Experimental support for [MSC3970](https://github.com/matrix-org/matrix-spec-proposals/pull/3970): Scope transaction IDs to devices. ([\#15318](https://github.com/matrix-org/synapse/issues/15318))
- Add an [admin API endpoint](https://matrix-org.github.io/synapse/v1.83/admin_api/experimental_features.html) to support per-user feature flags. ([\#15344](https://github.com/matrix-org/synapse/issues/15344))
- Add a module API to send an HTTP push notification. ([\#15387](https://github.com/matrix-org/synapse/issues/15387))
- Add an [admin API endpoint](https://matrix-org.github.io/synapse/v1.83/admin_api/statistics.html#get-largest-rooms-by-size-in-database) to query the largest rooms by disk space used in the database. ([\#15482](https://github.com/matrix-org/synapse/issues/15482))


Bugfixes
--------

- Disable push rule evaluation for rooms excluded from sync. ([\#15361](https://github.com/matrix-org/synapse/issues/15361))
- Fix a long-standing bug where cached server key results which were directly fetched would not be properly re-used. ([\#15417](https://github.com/matrix-org/synapse/issues/15417))
- Fix a bug introduced in Synapse 1.73.0 where some experimental push rules were returned by default. ([\#15494](https://github.com/matrix-org/synapse/issues/15494))


Improved Documentation
----------------------

- Add Nginx loadbalancing example with sticky mxid for workers. ([\#15411](https://github.com/matrix-org/synapse/issues/15411))
- Update outdated development docs that mention restrictions in versions of SQLite that we no longer support. ([\#15498](https://github.com/matrix-org/synapse/issues/15498))


Internal Changes
----------------

- Speedup tests by caching HomeServerConfig instances. ([\#15284](https://github.com/matrix-org/synapse/issues/15284))
- Add denormalised event stream ordering column to membership state tables for future use. Contributed by Nick @ Beeper (@fizzadar). ([\#15356](https://github.com/matrix-org/synapse/issues/15356))
- Always use multi-user device resync replication endpoints. ([\#15418](https://github.com/matrix-org/synapse/issues/15418))
- Add column `full_user_id` to tables `profiles` and `user_filters`. ([\#15458](https://github.com/matrix-org/synapse/issues/15458))
- Update support for [MSC3983](https://github.com/matrix-org/matrix-spec-proposals/pull/3983) to allow always returning fallback-keys in a `/keys/claim` request. ([\#15462](https://github.com/matrix-org/synapse/issues/15462))
- Improve type hints. ([\#15465](https://github.com/matrix-org/synapse/issues/15465), [\#15496](https://github.com/matrix-org/synapse/issues/15496), [\#15497](https://github.com/matrix-org/synapse/issues/15497))
- Support claiming more than one OTK at a time. ([\#15468](https://github.com/matrix-org/synapse/issues/15468))
- Bump types-pyyaml from 6.0.12.8 to 6.0.12.9. ([\#15471](https://github.com/matrix-org/synapse/issues/15471))
- Bump pyasn1-modules from 0.2.8 to 0.3.0. ([\#15473](https://github.com/matrix-org/synapse/issues/15473))
- Bump cryptography from 40.0.1 to 40.0.2. ([\#15474](https://github.com/matrix-org/synapse/issues/15474))
- Bump types-netaddr from 0.8.0.7 to 0.8.0.8. ([\#15475](https://github.com/matrix-org/synapse/issues/15475))
- Bump types-jsonschema from 4.17.0.6 to 4.17.0.7. ([\#15476](https://github.com/matrix-org/synapse/issues/15476))
- Ask bug reporters to provide logs as text. ([\#15479](https://github.com/matrix-org/synapse/issues/15479))
- Add a Nix flake for use as a development environment. ([\#15495](https://github.com/matrix-org/synapse/issues/15495))
- Bump anyhow from 1.0.70 to 1.0.71. ([\#15507](https://github.com/matrix-org/synapse/issues/15507))
- Bump types-pillow from 9.4.0.19 to 9.5.0.2. ([\#15508](https://github.com/matrix-org/synapse/issues/15508))
- Bump packaging from 23.0 to 23.1. ([\#15510](https://github.com/matrix-org/synapse/issues/15510))
- Bump types-requests from 2.28.11.16 to 2.29.0.0. ([\#15511](https://github.com/matrix-org/synapse/issues/15511))
- Bump setuptools-rust from 1.5.2 to 1.6.0. ([\#15512](https://github.com/matrix-org/synapse/issues/15512))
- Update the check_schema_delta script to account for when the schema version has been bumped locally. ([\#15466](https://github.com/matrix-org/synapse/issues/15466))


Synapse 1.82.0 (2023-04-25)
===========================

Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions debian/changelog
@@ -1,3 +1,15 @@
matrix-synapse-py3 (1.83.0) stable; urgency=medium

* New Synapse release 1.83.0.

-- Synapse Packaging team <packages@matrix.org> Tue, 09 May 2023 18:13:37 +0200

matrix-synapse-py3 (1.83.0~rc1) stable; urgency=medium

* New Synapse release 1.83.0rc1.

-- Synapse Packaging team <packages@matrix.org> Tue, 02 May 2023 15:56:38 +0100

matrix-synapse-py3 (1.82.0) stable; urgency=medium

* New Synapse release 1.82.0.
Expand Down
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Expand Up @@ -57,6 +57,7 @@
- [Account Validity](admin_api/account_validity.md)
- [Background Updates](usage/administration/admin_api/background_updates.md)
- [Event Reports](admin_api/event_reports.md)
- [Experimental Features](admin_api/experimental_features.md)
- [Media](admin_api/media_admin_api.md)
- [Purge History](admin_api/purge_history_api.md)
- [Register Users](admin_api/register_api.md)
Expand Down
54 changes: 54 additions & 0 deletions docs/admin_api/experimental_features.md
@@ -0,0 +1,54 @@
# Experimental Features API

This API allows a server administrator to enable or disable some experimental features on a per-user
basis. Currently supported features are [msc3026](https://github.com/matrix-org/matrix-spec-proposals/pull/3026): busy
presence state enabled, [msc2654](https://github.com/matrix-org/matrix-spec-proposals/pull/2654): enable unread counts,
[msc3881](https://github.com/matrix-org/matrix-spec-proposals/pull/3881): enable remotely toggling push notifications
for another client, and [msc3967](https://github.com/matrix-org/matrix-spec-proposals/pull/3967): do not require
UIA when first uploading cross-signing keys.


To use it, you will need to authenticate by providing an `access_token`
for a server admin: see [Admin API](../usage/administration/admin_api/).

## Enabling/Disabling Features

This API allows a server administrator to enable experimental features for a given user. The request must
provide a body containing the user id and listing the features to enable/disable in the following format:
```json
{
"features": {
"msc3026":true,
"msc2654":true
}
}
```
where true is used to enable the feature, and false is used to disable the feature.


The API is:

```
PUT /_synapse/admin/v1/experimental_features/<user_id>
```

## Listing Enabled Features

To list which features are enabled/disabled for a given user send a request to the following API:

```
GET /_synapse/admin/v1/experimental_features/<user_id>
```

It will return a list of possible features and indicate whether they are enabled or disabled for the
user like so:
```json
{
"features": {
"msc3026": true,
"msc2654": true,
"msc3881": false,
"msc3967": false
}
}
```
49 changes: 49 additions & 0 deletions docs/admin_api/statistics.md
Expand Up @@ -81,3 +81,52 @@ The following fields are returned in the JSON response body:
- `user_id` - string - Fully-qualified user ID (ex. `@user:server.com`).
* `next_token` - integer - Opaque value used for pagination. See above.
* `total` - integer - Total number of users after filtering.


# Get largest rooms by size in database

Returns the 10 largest rooms and an estimate of how much space in the database
they are taking.

This does not include the size of any associated media associated with the room.

Returns an error on SQLite.

*Note:* This uses the planner statistics from PostgreSQL to do the estimates,
which means that the returned information can vary widely from reality. However,
it should be enough to get a rough idea of where database disk space is going.


The API is:

```
GET /_synapse/admin/v1/statistics/statistics/database/rooms
```

A response body like the following is returned:

```json
{
"rooms": [
{
"room_id": "!OGEhHVWSdvArJzumhm:matrix.org",
"estimated_size": 47325417353
}
],
}
```



**Response**

The following fields are returned in the JSON response body:

* `rooms` - An array of objects, sorted by largest room first. Objects contain
the following fields:
- `room_id` - string - The room ID.
- `estimated_size` - integer - Estimated disk space used in bytes by the room
in the database.


*Added in Synapse 1.83.0*
34 changes: 1 addition & 33 deletions docs/development/database_schema.md
Expand Up @@ -155,43 +155,11 @@ def run_upgrade(
Boolean columns require special treatment, since SQLite treats booleans the
same as integers.

There are three separate aspects to this:

* Any new boolean column must be added to the `BOOLEAN_COLUMNS` list in
Any new boolean column must be added to the `BOOLEAN_COLUMNS` list in
`synapse/_scripts/synapse_port_db.py`. This tells the port script to cast
the integer value from SQLite to a boolean before writing the value to the
postgres database.

* Before SQLite 3.23, `TRUE` and `FALSE` were not recognised as constants by
SQLite, and the `IS [NOT] TRUE`/`IS [NOT] FALSE` operators were not
supported. This makes it necessary to avoid using `TRUE` and `FALSE`
constants in SQL commands.

For example, to insert a `TRUE` value into the database, write:

```python
txn.execute("INSERT INTO tbl(col) VALUES (?)", (True, ))
```

* Default values for new boolean columns present a particular
difficulty. Generally it is best to create separate schema files for
Postgres and SQLite. For example:

```sql
# in 00delta.sql.postgres:
ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT FALSE;
```

```sql
# in 00delta.sql.sqlite:
ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT 0;
```

Note that there is a particularly insidious failure mode here: the Postgres
flavour will be accepted by SQLite 3.22, but will give a column whose
default value is the **string** `"FALSE"` - which, when cast back to a boolean
in Python, evaluates to `True`.


## `event_id` global uniqueness

Expand Down
66 changes: 64 additions & 2 deletions docs/workers.md
Expand Up @@ -325,8 +325,7 @@ load balancing can be done in different ways.

For `/sync` and `/initialSync` requests it will be more efficient if all
requests from a particular user are routed to a single instance. This can
be done e.g. in nginx via IP `hash $http_x_forwarded_for;` or via
`hash $http_authorization consistent;` which contains the users access token.
be done in reverse proxy by extracting username part from the users access token.

Admins may additionally wish to separate out `/sync`
requests that have a `since` query parameter from those that don't (and
Expand All @@ -335,6 +334,69 @@ when a user logs in on a new device and can be *very* resource intensive, so
isolating these requests will stop them from interfering with other users ongoing
syncs.

Example `nginx` configuration snippet that handles the cases above. This is just an
example and probably requires some changes according to your particular setup:

```nginx
# Choose sync worker based on the existence of "since" query parameter
map $arg_since $sync {
default synapse_sync;
'' synapse_initial_sync;
}
# Extract username from access token passed as URL parameter
map $arg_access_token $accesstoken_from_urlparam {
# Defaults to just passing back the whole accesstoken
default $arg_access_token;
# Try to extract username part from accesstoken URL parameter
"~syt_(?<username>.*?)_.*" $username;
}
# Extract username from access token passed as authorization header
map $http_authorization $mxid_localpart {
# Defaults to just passing back the whole accesstoken
default $http_authorization;
# Try to extract username part from accesstoken header
"~Bearer syt_(?<username>.*?)_.*" $username;
# if no authorization-header exist, try mapper for URL parameter "access_token"
"" $accesstoken_from_urlparam;
}
upstream synapse_initial_sync {
# Use the username mapper result for hash key
hash $mxid_localpart consistent;
server 127.0.0.1:8016;
server 127.0.0.1:8036;
}
upstream synapse_sync {
# Use the username mapper result for hash key
hash $mxid_localpart consistent;
server 127.0.0.1:8013;
server 127.0.0.1:8037;
server 127.0.0.1:8038;
server 127.0.0.1:8039;
}
# Sync initial/normal
location ~ ^/_matrix/client/(r0|v3)/sync$ {
proxy_pass http://$sync;
}
# Normal sync
location ~ ^/_matrix/client/(api/v1|r0|v3)/events$ {
proxy_pass http://synapse_sync;
}
# Initial_sync
location ~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$ {
proxy_pass http://synapse_initial_sync;
}
location ~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$ {
proxy_pass http://synapse_initial_sync;
}
```

Federation and client requests can be balanced via simple round robin.

The inbound federation transaction request `^/_matrix/federation/v1/send/`
Expand Down

0 comments on commit 06806f4

Please sign in to comment.