Skip to content

release: Famedly Synapse v1.160.0_1 - #284

Merged
FrenchGithubUser merged 31 commits into
masterfrom
famedly-release/v1.160
Sep 8, 2026
Merged

release: Famedly Synapse v1.160.0_1#284
FrenchGithubUser merged 31 commits into
masterfrom
famedly-release/v1.160

Conversation

@FrenchGithubUser

@FrenchGithubUser FrenchGithubUser commented Sep 7, 2026

Copy link
Copy Markdown
Member

reivilibre and others added 30 commits August 11, 2026 17:31
…ion. (#20089)

[As discussed in Backend
Lobby](https://matrix.to/#/!SGNQGPGUwtcPBUotTL:matrix.org/$jz87yx9uFcwKYhwejCLiVlfRLKseUHRnRrz2jZcGvOs?via=jki.re&via=element.io&via=matrix.org)

As for justification for calling this the recommended way,

- from memory this is accurate
- a previous changelog implies this:
https://github.com/element-hq/synapse/blob/287904c03ac8892407be960d475c4d25007e8917/docs/changelogs/CHANGES-2022.md?plain=1#L1296
- this is what we are doing internally ([Backend Lobby
example](https://matrix.to/#/!SGNQGPGUwtcPBUotTL:matrix.org/$MTCVg5-D0k_jq9QZxVSSy1CeMGs8mbG6ld-BWOOy9JI?via=jki.re&via=element.io&via=matrix.org))

I can't find a definitive source though

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
… (every 1m) (#20093)

(`_wait_for_actions`)

Spawning from seeing the release CI being complete but needing to wait
up to 5 minutes longer to continue on.

### Dev notes

Originally the waiting was introduced in
matrix-org/synapse#13483

GitHub rate limit:

> The primary rate limit for unauthenticated requests is 60 requests per
hour.
>
> *-- https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2026-03-10#primary-rate-limit-for-unauthenticated-users*
From
element-hq/synapse#19875 (comment).
I was unable to do so on the PR quickly as the branch was not available
for maintainers to edit.
…heduled tasks admin API (#20067)

We have an internal usage of `/scheduled_tasks` that would like to fetch
multiple actions at once (janitor).

We also make it so that invalid `status` values now return a 400 rather
than a 500.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Issue spotted in: element-hq/synapse#20098

Follows: #20027

We already use `faketime` for Postgres, but I forgot that the SQLite
schema delta would have the same problem
and somehow tuned it out of the preview diff on the original PR.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
This is a fix for presence updates silently stalling when a `/sync`
request is cancelled mid-write, causing a stream ID to be leaked into
`_unfinished_ids` and permanently pinning the persisted stream position.

Fixes element-hq/synapse#19800

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
…0117)

Follows: #20027

Noticed in element-hq/synapse#20003

The problem was that `--no-root` prevents reinstalling the root project
(Synapse).
However, since we just did a `git checkout`, we need to reinstall the
root project in case the Rust code changed, as the
`poetry install` command is what causes the Rust to be recompiled.

Doing otherwise causes the 'Rust module outdated' error when importing
`synapse`.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
The conversion of `device_lists_changes_in_room` rows into
`device_lists_outbound_pokes` is DB-bound on
`mark_redundant_device_lists_pokes`. The `UPDATE` uses the `(room_id,
stream_id)` index, so each call scans the unconverted backlog, getting
slower the further behind the conversion is.

Add a partial index matching the query via a background update, and skip
the (safe-to-skip) `UPDATE` until the index has been built. Also add a
metric reporting how far behind the conversion is, using the existing
`inserted_ts` column.

Fixes element-hq/backend-internal#286

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Eric Eastwood <erice@element.io>
…database (#20120)

### Background

On `matrix.org`, since 2026-08-15, we are seeing the database CPU being
saturated more than usual
([grafana](https://grafana.matrix.org/d/rYdddlPWk/node-exporter?orgId=1&from=2026-08-10T23:23:14.237Z&to=2026-08-17T23:23:14.237Z&timezone=browser&var-DS_PROMETHEUS=default&var-job=machine&var-node=matrix-db-01.matrix.org:9100&var-diskdevices=%5Ba-z%5D%2B%7Cnvme%5B0-9%5D%2Bn%5B0-9%5D%2B&refresh=1m&viewPanel=panel-77))

<img width="919" height="265" alt="CPU of database server"
src="https://github.com/user-attachments/assets/9a43cf3c-bf9a-4ade-b70e-0bf0fb53f0ef"
/>


@reivilibre
[found](https://matrix.to/#/!yHWhpxlXVaLcsgDUKb:matrix.org/$fUMf60IbFocpEuJNbmbEzFiCyKCFnAl4I4XpB27DUQs?via=banzan.uk&via=element.io&via=matrix.org)
`mark_as_sent_devices_by_remote` spiking in the `DB transactions by
total txn time` graph
([grafana](https://grafana.matrix.org/d/000000012/synapse?var-bucket_size=$__auto&orgId=1&from=2026-08-10T22:26:07.336Z&to=2026-08-17T22:26:07.336Z&timezone=browser&var-datasource=default&var-instance=matrix.org&var-job=synapse_federation_sender&var-index=$__all&showCategory=Thresholds&viewPanel=panel-11))

<img width="919" height="269" alt="'mark_as_sent_devices_by_remote'
spiking in the 'DB transactions by total txn time' graph"
src="https://github.com/user-attachments/assets/9336ce29-c045-4940-9c46-9e4906300f2d"
/>

And we indeed see a bunch of time being spent on
`mark_as_sent_devices_by_remote` by looking at `pg_stat_statements`. The
top two queries we're spending CPU on are the `SELECT` and `DELETE`
statements in
[`mark_as_sent_devices_by_remote`](https://github.com/element-hq/synapse/blob/94a5f2afb36a4afdc36813fd1c24b9a1c4aec252/synapse/storage/databases/main/devices.py#L922-L950).


We also did some related work in this area recently with
element-hq/synapse#20098 although it was
tackling a different bottle-neck.


### This PR

This PRs combines the two separate `SELECT` and `DELETE` queries which
touch the same data into one `DELETE ... RETURNING ...` query. this
means we get to save the cost of one of those statements (less CPU on
the database) and fewer statements per transaction (less round-trips)
means connections turn over faster, and can move on to process the next
thing.

This is a micro-optimization I spotted while reading
[`_mark_as_sent_devices_by_remote_txn`](https://github.com/element-hq/synapse/blob/develop/synapse/storage/databases/main/devices.py#L922-L950)
rather than a structural fix. I'm sure there are even better things to
do to where we could even avoid this kind of work altogether but this
seemed like a quick win especially given how much this particular
transaction is saturating the database.

Doing things faster doesn't necessarily mean we solve the
saturated/starved CPU problem but it does mean the same task costs less
CPU.

From the `pg_stat_statements` samples above, we can expect to be up to
~27% more efficient with database CPU on this code path (derived from
the `cpus_busy` numbers above `22.932 / (22.932 + 61.956)`). We're
removing the `SELECT` (`61.956` `cpus_busy`) but I still expect the
`DELETE` (`22.932` `cpus_busy`) to take on a similar cost as I'm sure
it's a warm cache situation between them.
…member queries (#19974)

This is another stopgap towards
element-hq/voip-internal#641 and adds
experimental support for
[MSC4502](matrix-org/matrix-spec-proposals#4502).

This adds a new endpoint `/rooms/{roomId}/is_joined` to query if a user
or server is joined to a room known to the homeserver. Access to the
endpoint is guarded behind a new OAuth scope that can be assigned when
registering application services.

Tracking issue: element-hq/synapse#20118

---------

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
Follows: #20117

schema_diff: Move faketime so it doesn't affect `poetry install`

Caused a hang in the CI for
element-hq/synapse#20003
whilst recompiling the Rust module (it seems)

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
…ata (#20124)

Noticed while working on
element-hq/synapse#20003, submitting separately.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Eric Eastwood <erice@element.io>
Signed-off-by: cat <cat@plan9.rocks>
This PR implements support for profile updates over Sliding Sync:
matrix-org/matrix-spec-proposals#4262. This pr
may be easier to review as a whole than commit by commit.

This builds on the legacy sync profile updates feature
element-hq/synapse#19556, specifically the
profile updates stream it added.

Submitting for early review to get consensus on implementation. There
are some things we would like to add still, from spec, mainly:

* > Homeservers should only consider a profile field update "accepted"
by a client
> once the client returns with a new /sync request with the next /sync
token,
> NOT just after sending down the profile update. The client may never
receive
> response due to network conditions, or a bug in the client
implementation.
* > When a room enters this subset in this connection for the first
time, all requested
> fields from profiles of users in that room MAY be sent down. This
gives the client
> a base set of information for which future field updates can be
applied on top of.
> The homeserver MAY omit some fields and profiles if it believes that
the client has
> already received them, likewise repeat profiles MAY be sent down based
on homeserver
  > implementation.
* > Finally, if the list of fields expands to cover a new field ID,
those fields should
> be sent down for all users that are within the current room subset.
Future incremental
  > updates will then include changes to this field.
* Additionally, we would need to implement a lazy loading cache similar
to the legacy sync. (not part of MSC as such)

Depending on review these could either be added to this pr, or to keep
this pr from not growing too much, be added in a follow-up pr, as they
are more enhancement to this base sliding sync profile updates
functionality than a part of the core functionality.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Olivier 'reivilibre' <olivier@librepush.net>
Co-authored-by: Olivier 'reivilibre <oliverw@element.io>
…d without belonging to any rooms (#20135)

Fix sync stream not being woken up when a user updates a profile field
without belonging to any rooms.

Fixes element-hq/synapse#20110
When a client (correctly) calls the `DELETE` endpoint to remove a custom
profile field (like Element X does with `m.status`), we incorrectly
don't include it in the sync response in legacy sync. This was due to
the fact that we cleaned up the sent fields down to what fields the
profile currently has.

Always ensure any fields in `ProfileUpdateAction.UPDATE` are sent down,
as `null` values for profile fields which have been deleted.

Fixes an issue where clearing a user status from Element X does not
reflect in the user status being cleared on Element Web.

Note, target is the v1.160.0 release branch due to customer commitments,
and this fixes web and mobile clients not working together correctly.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [ ] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
@FrenchGithubUser
FrenchGithubUser marked this pull request as ready for review September 7, 2026 11:06
@FrenchGithubUser
FrenchGithubUser requested a review from a team as a code owner September 7, 2026 11:06

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 86cffa3. Configure here.

Comment thread synapse/handlers/sliding_sync/extensions.py
Comment thread synapse/handlers/sliding_sync/extensions.py
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.66667% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.93%. Comparing base (570ad41) to head (86cffa3).

Files with missing lines Patch % Lines
synapse/handlers/sliding_sync/extensions.py 89.90% 5 Missing and 6 partials ⚠️
synapse/media/thumbnailer.py 80.00% 3 Missing ⚠️
synapse/storage/databases/main/profile.py 85.71% 0 Missing and 3 partials ⚠️
synapse/storage/background_updates.py 66.66% 1 Missing and 1 partial ⚠️
synapse/storage/databases/main/devices.py 89.47% 1 Missing and 1 partial ⚠️
synapse/rest/client/sync.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #284      +/-   ##
==========================================
+ Coverage   80.87%   80.93%   +0.06%     
==========================================
  Files         504      505       +1     
  Lines       72717    72978     +261     
  Branches    10973    11035      +62     
==========================================
+ Hits        58807    59062     +255     
- Misses      10621    10624       +3     
- Partials     3289     3292       +3     
Files with missing lines Coverage Δ
synapse/api/auth/__init__.py 100.00% <100.00%> (ø)
synapse/api/auth/base.py 90.47% <100.00%> (+0.73%) ⬆️
synapse/api/constants.py 100.00% <ø> (ø)
synapse/appservice/__init__.py 84.90% <100.00%> (+0.79%) ⬆️
synapse/config/appservice.py 65.16% <100.00%> (+1.21%) ⬆️
synapse/config/experimental.py 84.26% <100.00%> (+0.17%) ⬆️
synapse/config/server.py 69.02% <ø> (ø)
synapse/handlers/device.py 75.88% <100.00%> (+0.59%) ⬆️
synapse/handlers/profile.py 71.51% <100.00%> (+1.51%) ⬆️
synapse/handlers/sync.py 84.51% <100.00%> (ø)
... and 17 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 570ad41...86cffa3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@FrenchGithubUser
FrenchGithubUser added this pull request to the merge queue Sep 8, 2026
Merged via the queue into master with commit bd09672 Sep 8, 2026
76 checks passed
@FrenchGithubUser
FrenchGithubUser deleted the famedly-release/v1.160 branch September 8, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.