summary refs log tree commit diff
path: root/synapse/storage (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix performance of device lists in `/key/changes` and sliding sync (#17537) HEAD developErik Johnston2024-08-091-0/+5
| | | | | | We do this by reusing the code from sync v2. Reviewable commit-by-commit. The function `get_user_ids_changed` has been rewritten entirely, so I would recommend not looking at the diff.
* Sliding Sync: Use `stream_ordering` based timeline pagination for ↵Eric Eastwood2024-08-071-85/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | incremental sync (#17510) Use `stream_ordering` based `timeline` pagination for incremental `/sync` in Sliding Sync. Previously, we were always using a `topological_ordering` but we should only be using that for historical scenarios (initial `/sync`, newly joined, or haven't sent the room down the connection before). This is slightly different than what the [spec suggests](https://spec.matrix.org/v1.10/client-server-api/#syncing) > Events are ordered in this API according to the arrival time of the event on the homeserver. This can conflict with other APIs which order events based on their partial ordering in the event graph. This can result in duplicate events being received (once per distinct API called). Clients SHOULD de-duplicate events based on the event ID when this happens. But we've had a [discussion below in this PR](https://github.com/element-hq/synapse/pull/17510#discussion_r1699105569) and this matches what Sync v2 already does and seems like it makes sense. Created a spec issue https://github.com/matrix-org/matrix-spec/issues/1917 to clarify this. Related issues: - https://github.com/matrix-org/matrix-spec/issues/1917 - https://github.com/matrix-org/matrix-spec/issues/852 - https://github.com/matrix-org/matrix-spec-proposals/pull/4033
* Sliding Sync: Add more tracing (#17514)Eric Eastwood2024-08-063-1/+9
| | | | | | | | | | | | Spawning from looking at a couple traces and wanting a little more info. Follow-up to github.com/element-hq/synapse/pull/17501 The changes in this PR allow you to find slow Sliding Sync traces ignoring the `wait_for_events` time. In Jaeger, you can now filter for the `current_sync_for_user` operation with `RESULT.result=true` indicating that it actually returned non-empty results. If you want to find traces for your own user, you can use `RESULT.result=true ARG.sync_config.user="@madlittlemods:matrix.org"`
* Sliding Sync: Update filters to be robust against remote invite rooms (#17450)Eric Eastwood2024-07-303-36/+205
| | | | | | | | | | | | | | | Update `filters.is_encrypted` and `filters.types`/`filters.not_types` to be robust when dealing with remote invite rooms in Sliding Sync. Part of [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync Follow-up to https://github.com/element-hq/synapse/pull/17434 We now take into account current state, fallback to stripped state for invite/knock rooms, then historical state. If we can't determine the info needed to filter a room (either from state or stripped state), it is filtered out.
* Only send rooms with updates down sliding sync (#17479)Erik Johnston2024-07-301-0/+10
| | | | | | | | | | | | Rather than always including all rooms in range. Also adds a pre-filter to rooms that checks the stream change cache to see if anything might have happened. Based on #17447 --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Sliding Sync: Track whether we have sent rooms down to clients (#17447)Erik Johnston2024-07-291-0/+37
| | | | | | | | | | | | | | | | The basic idea is that we introduce a new token for a sliding sync connection, which stores the mapping of room to room "status" (i.e. have we sent the room down?). This token allows us to handle duplicate requests properly. In future it can be used to store more "per-connection" information safely. In future this should be migrated into the DB, so its important that we try to reduce the number of syncs where we need to update the per-connection information. In this PoC this only happens when we: a) send down a set of room for the first time, or b) we have previously sent down a room and there are updates but we are not sending the room down the sync (due to not falling in a list range) Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Speed up SS room sorting (#17468)Erik Johnston2024-07-232-1/+127
| | | | | | | We do this by bulk fetching the latest stream ordering. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Prepare for authenticated media freeze (#17433)Shay2024-07-223-2/+46
| | | | | | As part of the rollout of [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3916-authentication-for-media.md) this PR adds support for designating authenticated media and ensuring that authenticated media is not served over unauthenticated endpoints.
* Add a cache on `get_rooms_for_local_user_where_membership_is` (#17460)Erik Johnston2024-07-193-3/+35
| | | | | | | As it gets used in sliding sync. We basically invalidate it in all the same places as `get_rooms_for_user`. Most of the changes are due to needing the arguments you pass in to be hashable (which lists aren't)
* Order `heroes` by `stream_ordering` (as spec'ed) (#17435)Eric Eastwood2024-07-171-12/+45
| | | | | | | | | | | | | The spec specifically mentions `stream_ordering` but that's a Synapse specific concept. In any case, the essence of the spec is basically the first 5 members of the room which `stream_ordering` accomplishes. Split off from https://github.com/element-hq/synapse/pull/17419#discussion_r1671342794 ## Spec compliance > This should be the first 5 members of the room, **ordered by stream ordering**, which are joined or invited. The list must never include the client’s own user ID. When no joined or invited members are available, this should consist of the banned and left users. > > *-- https://spec.matrix.org/v1.10/client-server-api/#_matrixclientv3sync_roomsummary* Related to https://github.com/matrix-org/matrix-spec/issues/1334
* Fix filtering room types on remote rooms (#17434)Erik Johnston2024-07-111-1/+51
| | | | | | We can only fetch room types for rooms the server is in, so we need to only filter rooms that we're joined to. Also includes a perf fix to bulk fetch room types.
* Fix bug in sliding sync when using old DB. (#17398)Erik Johnston2024-07-085-88/+31
| | | | | | | | | We don't necessarily have `instance_name` for old events (before we support multiple event persisters). We treat those as if the `instance_name` was "master". --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Add `rooms.bump_stamp` to Sliding Sync `/sync` for easier client-side ↵Eric Eastwood2024-07-081-11/+24
| | | | | | | | | | | | | | | sorting (#17395) `bump_stamp` corresponds to the `stream_ordering` of the latest `DEFAULT_BUMP_EVENT_TYPES` in the room. This helps clients sort more readily without them needing to pull in a bunch of the timeline to determine the last activity. `bump_event_types` is a thing because for example, we don't want display name changes to mark the room as unread and bump it to the top. For encrypted rooms, we just have to consider any activity as a bump because we can't see the content and the client has to figure it out for themselves. Outside of Synapse, `bump_stamp` is just a free-form counter so other implementations could use `received_ts`or `origin_server_ts` (see the [*Security considerations* section in MSC3575 about the potential pitfalls of using `origin_server_ts`](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/sync-v3/proposals/3575-sync.md#security-considerations)). It doesn't have any guarantee about always going up. In the Synapse case, it could go down if an event was redacted/removed (or purged in cases of retention policies). In the future, we could add `bump_event_types` as [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575) mentions if people need to customize the event types. --- In the Sliding Sync proxy, a similar [`timestamp` field was added](https://github.com/matrix-org/sliding-sync/pull/247) for the same purpose but the name is not obvious what it pertains to or what it's for. The `timestamp` field was also added to Ruma in https://github.com/ruma/ruma/pull/1622
* Finish up work to allow per-user feature flags (#17392)Erik Johnston2024-07-051-9/+55
| | | | | | | Follows on from @H-Shay's great work at https://github.com/matrix-org/synapse/pull/15344 and MSC4026. Also enables its use for MSC3881, mainly as an easy but concrete example of how to use it.
* Add `rooms.required_state` to Sliding Sync `/sync` (#17342)Eric Eastwood2024-07-041-1/+25
| | | Also handles excluding rooms with partial state when people are asking for room membership events unless it's `$LAZY` room membership.
* Add `room_types`/`not_room_types` filtering to Sliding Sync `/sync` (#17337)Eric Eastwood2024-07-021-0/+3
| | | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Return some room data in Sliding Sync `/sync` (#17320)Eric Eastwood2024-07-023-15/+284
| | | | | | - Timeline events - Stripped `invite_state` Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Fix sync waiting for an invalid token from the "future" (#17386)Erik Johnston2024-07-0211-28/+65
| | | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/issues/17274, hopefully. Basically, old versions of Synapse could advance streams without persisting anything in the DB (fixed in #17229). On restart those updates would get lost, and so the position of the stream would revert to an older position. If this happened across an upgrade to a later Synapse version which included #17215, then sync could get blocked indefinitely (until the stream advanced to the position in the token). We fix this by bounding the stream positions we'll wait for to the maximum position of the underlying stream ID generator.
* Handle multiple rows device inbox (#17362)Erik Johnston2024-06-271-3/+2
| | | | | | | | | | Fix bug where we don't get new to-device from remote if they resent a message we've already persisted and have recorded in the DB twice. `device_federation_inbox` table doesn't have a unique index, and so we can race and store an entry in there twice. If we do so then `simple_select_one_txn` will throw an error due to the query returning more than one row. We should add an unique index, but it doesn't really matter so lets just handle the case of multiple rows correctly for now.
* Limit amount of replication we send (#17358)Erik Johnston2024-06-251-8/+7
| | | | | | | | | Fixes up #17333, where we failed to actually send less data (the `DISTINCT` didn't work due to `stream_id` being different). We fix this by making it so that every device list outbound poke for a given user ID has the same stream ID. We can't change the query to only return e.g. max stream ID as the receivers look up the destinations to send to by doing `SELECT WHERE stream_id = ?`
* Reintroduce "Reduce device lists replication traffic."" (#17361)Erik Johnston2024-06-252-37/+60
| | | | | | Reintroduces https://github.com/element-hq/synapse/pull/17333 Turns out the reason for revert was down two master instances running
* Revert "Reduce device lists replication traffic." (#17360)Erik Johnston2024-06-252-60/+37
| | | | | | Reverts element-hq/synapse#17333 It looks like master was still sending out replication RDATA with the old format... somehow
* Reintroduce #17291. (#17338)Erik Johnston2024-06-243-77/+206
| | | | | | | This is #17291 (which got reverted), with some added fixups, and change so that tests actually pick up the error. The problem was that we were not calculating any new chain IDs due to a missing `not` in a condition.
* Reduce device lists replication traffic. (#17333)Erik Johnston2024-06-242-37/+60
| | | | | | | | | | Reduce the replication traffic of device lists, by not sending every destination that needs to be sent the device list update over replication. Instead a "hosts to send to have been calculated" notification over replication, and then federation senders read the destinations from the DB. For non federation senders this should heavily reduce the impact of a user in many large rooms changing a device.
* Revert "Handle large chain calc better (#17291)" (#17334)Erik Johnston2024-06-192-191/+70
| | | | | | This reverts commit bdf82efea505c488953b46eb681b5a63c4e9655d (#17291) This seems to have stopped persisting auth chains for new events, and so is causing state res to fall back to the slow methods
* Filter added to Admin-API GET /rooms (#17276)Alexander Fechler2024-06-191-14/+37
|
* Handle large chain calc better (#17291)Erik Johnston2024-06-192-70/+191
| | | | | We calculate the auth chain links outside of the main persist event transaction to ensure that we do not block other event sending during the calculation.
* Require the 'from' parameter for `/notifications` be an integer (#17283)Andrew Morgan2024-06-191-1/+1
| | | | Co-authored-by: Erik Johnston <erikj@element.io>
* Add `is_encrypted` filtering to Sliding Sync `/sync` (#17281)Eric Eastwood2024-06-171-1/+86
| | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Add `stream_ordering` sort to Sliding Sync `/sync` (#17293)Eric Eastwood2024-06-171-6/+36
| | | Sort is no longer configurable and we always sort rooms by the `stream_ordering` of the last event in the room or the point where the user can see up to in cases of leave/ban/invite/knock.
* Merge branch 'release-v1.109' into developQuentin Gliech2024-06-172-25/+35
|\
| * Set our own stream position from the current sequence value on startup (#17309)Quentin Gliech2024-06-171-3/+20
| |
| * Automatically apply SQL for inconsistent sequence (#17305)Erik Johnston2024-06-141-22/+15
| | | | | | | | | | | | Rather than forcing the server operator to apply the SQL manually. This should be safe, as there should be only one writer for these sequences.
* | Add `event.internal_metadata.instance_name` (#17300)Eric Eastwood2024-06-132-6/+11
| | | | | | | | | | | | | | | | | | | | Add `event.internal_metadata.instance_name` (the worker instance that persisted the event) to go alongside the existing `event.internal_metadata.stream_ordering`. `instance_name` is useful to properly compare and query for events with a token since you need to compare both the `stream_ordering` and `instance_name` against the vector clock/`instance_map` in the `RoomStreamToken`. This is pre-requisite work and may be used in https://github.com/element-hq/synapse/pull/17293 Adding `event.internal_metadata.instance_name` was first mentioned in the initial Sliding Sync PR while pairing with @erikjohnston, see https://github.com/element-hq/synapse/pull/17187/commits/09609cb0dbca3a4cfd9fbf90cc962e765ec469c0#diff-5cd773fb307aa754bd3948871ba118b1ef0303f4d72d42a2d21e38242bf4e096R405-R410
* | Fix `get_last_event_in_room_before_stream_ordering(...)` finding the wrong ↵Eric Eastwood2024-06-131-10/+22
| | | | | | | | | | | | | | | | | | | | | | last event (#17295) PR where this was introduced: https://github.com/matrix-org/synapse/pull/14817 ### What does this affect? `get_last_event_in_room_before_stream_ordering(...)` is used in Sync v2 in a lot of different state calculations. `get_last_event_in_room_before_stream_ordering(...)` is also used in `/rooms/{roomId}/members`
* | Add report room API (MSC4151) (#17270)Travis Ralston2024-06-122-0/+52
| | | | | | | | | | | | | | | | https://github.com/matrix-org/matrix-spec-proposals/pull/4151 This is intended to be enabled by default for immediate use. When FCP is complete, the unstable endpoint will be dropped and stable endpoint supported instead - no backwards compatibility is expected for the unstable endpoint.
* | Merge branch 'release-v1.109' into developQuentin Gliech2024-06-112-9/+35
|\|
| * Fix bug where device lists would break sync (#17292)Erik Johnston2024-06-102-9/+35
| | | | | | | | | | | | | | | | | | | | If the stream ID in the unconverted table is ahead of the device lists ID gen, then it can break all /sync requests that had an ID from ahead of the table. The fix is to make sure we add the unconverted table to the list of tables we check at start up. Broke in https://github.com/element-hq/synapse/pull/17229
* | Handle hyphens in user dir search porperly (#17254)Erik Johnston2024-06-051-6/+60
| | | | | | c.f. #16675
* | Use fully-qualified `PersistedEventPosition` when returning `RoomsForUser` ↵Eric Eastwood2024-06-042-3/+13
|/ | | | | | | (#17265) Use fully-qualified `PersistedEventPosition` (`instance_name` and `stream_ordering`) when returning `RoomsForUser` to facilitate proper comparisons and `RoomStreamToken` generation. Spawning from https://github.com/element-hq/synapse/pull/17187 where we want to utilize this change
* In sync wait for worker to catch up since token (#17215)Erik Johnston2024-05-302-2/+16
| | | | | | | Otherwise things will get confused. An alternative would be to make sure that for lagging stream we don't return anything (and make sure the returned next_batch token doesn't go backwards). But that is a faff.
* Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator` ↵Erik Johnston2024-05-307-214/+164
| | | | | (#17229) Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator`, which is safer.
* Clean out invalid destinations from outbox (#17242)Erik Johnston2024-05-302-0/+91
| | | | We started ensuring we only insert valid destinations: https://github.com/element-hq/synapse/pull/17240
* Move towards using `MultiWriterIdGenerator` everywhere (#17226)Erik Johnston2024-05-298-215/+153
| | | | | | | | | | | | | | | There is a problem with `StreamIdGenerator` where it can go backwards over restarts when a stream ID is requested but then not inserted into the DB. This is problematic if we want to land #17215, and is generally a potential cause for all sorts of nastiness. Instead of trying to fix `StreamIdGenerator`, we may as well move to `MultiWriterIdGenerator` that does not suffer from this problem (the latest positions are stored in `stream_positions` table). This involves adding SQLite support to the class. This only changes id generators that were already using `MultiWriterIdGenerator` under postgres, a separate PR will move the rest of the uses of `StreamIdGenerator` over.
* Don't invalidate all `get_relations_for_event` on history purge (#17083)Erik Johnston2024-05-294-12/+39
| | | | This is a tree cache already, so may as well move the room ID to the front and use that
* Change allow_unsafe_locale to also apply on new databases (#17238)Erik Johnston2024-05-291-1/+7
| | | | We relax this as there are use cases where this is safe, though it is still highly recommended that people avoid using it.
* Reduce work of calculating outbound device pokes (#17211)Erik Johnston2024-05-221-0/+24
|
* Improve perf of sync device lists (#17216)Erik Johnston2024-05-211-21/+68
| | | | | | | | Re-introduces #17191, and includes #17197 and #17214 The basic idea is to stop calling `get_rooms_for_user` everywhere, and instead use the table `device_lists_changes_in_room`. Commits reviewable one-by-one.
* Revert "Improve perf of sync device lists" (#17207)Erik Johnston2024-05-161-2/+15
| | | Reverts element-hq/synapse#17191
* Improve perf of sync device lists (#17191)Erik Johnston2024-05-141-15/+2
| | | | | It's almost always more efficient to query the rooms that have device list changes, rather than looking at the list of all users whose devices have changed and then look for shared rooms.
* Actually fix public rooms (#17184)Erik Johnston2024-05-131-54/+54
| | | | | See #17177. I'm an idiot and moved them to the wrong store :facepalm:
* Fix bug with creating public rooms on workers (#17177)Erik Johnston2024-05-131-65/+51
| | | | | | If room publication is disabled then creating public rooms on workers would not work. Introduced in #16811.
* Add support for MSC3823 - Account Suspension (#17051)Shay2024-05-013-2/+72
|
* Fix filtering of rooms when supplying the `destination` query parameter to ↵Andrew Morgan2024-04-261-0/+1
| | | | `/_synapse/admin/v1/federation/destinations/<destination>/rooms` (#17077)
* Return the search terms as search highlights for SQLite instead of nothing ↵Melvyn Laïly2024-04-261-7/+24
| | | | | | | (#17000) Fixes https://github.com/element-hq/synapse/issues/16999 and https://github.com/element-hq/element-android/pull/8729 by returning the search terms as search highlights.
* Redact membership events if the user requested erasure upon deactivating ↵Till2024-04-251-0/+22
| | | | | (#17076) Fixes #15355 by redacting all membership events before leaving rooms.
* Add type annotation to `visited_chains` (#17125)Andrew Morgan2024-04-251-1/+1
| | | | | This should fix CI on `develop`. Broke in https://github.com/element-hq/synapse/commit/0fe9e1f7dafa80f3e02762f7ae75cefee5b3316c, presumably due to a `mypy` dependency upgrade.
* Merge branch 'master' into developErik Johnston2024-04-232-73/+43
|\
| * Fix GHSA-3h7q-rfh9-xm4vErik Johnston2024-04-232-73/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Weakness in auth chain indexing allows DoS from remote room members through disk fill and high CPU usage. A remote Matrix user with malicious intent, sharing a room with Synapse instances before 1.104.1, can dispatch specially crafted events to exploit a weakness in how the auth chain cover index is calculated. This can induce high CPU consumption and accumulate excessive data in the database of such instances, resulting in a denial of service. Servers in private federations, or those that do not federate, are not affected.
* | Fix remote receipts for events we don't have (#17096)Erik Johnston2024-04-171-1/+5
| | | | | | Introduced in #17032
* | Use receipts `event_stream_ordering` instead of joins (#17032)Nick Mills-Barrett2024-04-122-19/+11
|/ | | | | | | | | | | | | | | | | | | | Resurrecting https://github.com/matrix-org/synapse/pull/13918. This should reduce IOPs incurred by joining to the events table to lookup stream ordering, which happens in many receipt handling code paths. Like the previous PR I believe sufficient time has passed between the original migration in DB schema 72 and now to merge this as-is. It's highly unlikely that both the migration is still ongoing AND (active) users still have any receipts prior to that date. In the unlikely event there is a receipt without a populated `event_stream_ordering` synapse will behave just as it does now when receipts exist for events that don't (yet): for push action calculation the receipts are just ignored. I've removed the validation on event IDs as this is already covered here: https://github.com/element-hq/synapse/blob/59ceabcb9798793cd4312fdbcced4e612aeda84d/synapse/handlers/receipts.py#L189-L192
* Add forgotten schema delta (#17054)Erik Johnston2024-04-092-7/+22
| | | This should have been in #17045. Whoops.
* Pull out fewer receipts from DB when doing push (#17049)Erik Johnston2024-04-051-22/+102
| | | | | | | Before we were pulling out *all* read receipts for a user for every event we pushed. Instead let's only pull out the relevant receipts. This also pulled out the event rows for each receipt, causing load on the events table.
* Add missing index to `access_tokens` table (#17045)Erik Johnston2024-04-041-0/+7
| | | This was causing sequential scans when using refresh tokens.
* Refactor chain fetching (#17044)Erik Johnston2024-04-021-96/+66
| | | Since these queries are duplicated in two places.
* Fixups to new push stream (#17038)Erik Johnston2024-03-281-1/+3
| | | Follow on from #17037
* Add support for moving `/push_rules` off of main process (#17037)Erik Johnston2024-03-282-28/+43
|
* Ensure that pending to-device events are sent over federation at startup ↵Richard van der Hoff2024-03-221-20/+79
| | | | | | | | | | | | | | (#16925) Fixes https://github.com/element-hq/synapse/issues/16680, as well as a related bug, where servers which we had *never* successfully sent an event to would not be retried. In order to fix the case of pending to-device messages, we hook into the existing `wake_destinations_needing_catchup` process, by extending it to look for destinations that have pending to-device messages. The federation transmission loop then attempts to send the pending to-device messages as normal.
* Do not refuse to set read_marker if previous event_id is in wrong room (#16990)SpiritCroc2024-03-211-3/+5
|
* Fix reject knocks on deactivating account (#17010)Hanadi2024-03-211-0/+16
|
* Clarify docs for some room state functions (#16950)Richard van der Hoff2024-03-191-3/+5
| | | | State *before* an event is different to state *after* that event, and people tend to assume the wrong one.
* Bump mypy from 1.5.1 to 1.8.0 (#16901)dependabot[bot]2024-03-132-5/+5
|
* Bump black from 23.10.1 to 24.2.0 (#16936)dependabot[bot]2024-03-1317-153/+109
|
* deactivated flag refactored to filter deactivated users. (#16874)Alexander Fechler2024-03-111-3/+6
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Fix joining remote rooms when a `on_new_event` callback is registered (#16973)Quentin Gliech2024-03-061-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Synapse 1.76.0, any module which registers a `on_new_event` callback would brick the ability to join remote rooms. This is because this callback tried to get the full state of the room, which would end up in a deadlock. Related: https://github.com/matrix-org/synapse-auto-accept-invite/issues/18 The following module would brick the ability to join remote rooms: ```python from typing import Any, Dict, Literal, Union import logging from synapse.module_api import ModuleApi, EventBase logger = logging.getLogger(__name__) class MyModule: def __init__(self, config: None, api: ModuleApi): self._api = api self._config = config self._api.register_third_party_rules_callbacks( on_new_event=self.on_new_event, ) async def on_new_event(self, event: EventBase, _state_map: Any) -> None: logger.info(f"Received new event: {event}") @staticmethod def parse_config(_config: Dict[str, Any]) -> None: return None ``` This is technically a breaking change, as we are now passing partial state on the `on_new_event` callback. However, this callback was broken for federated rooms since 1.76.0, and local rooms have full state anyway, so it's unlikely that it would change anything.
* Revert "Improve DB performance of calculating badge counts for push. ↵Andrew Morgan2024-03-051-146/+107
| | | | (#16756)" (#16979)
* bugfix: always prefer unthreaded receipt when >1 exist (MSC4102) (#16927)kegsay2024-02-201-3/+18
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Don't invalidate the entire event cache when we purge history (#16905)Erik Johnston2024-02-132-7/+9
| | | | | We do this by adding support to the LRU cache for "extra indices" based on the cached value. This allows us to efficiently map from room ID to the cached events and only invalidate those.
* Increase batching when fetching auth chains (#16893)Erik Johnston2024-02-091-2/+2
| | | | | | | | This basically reverts a change that was in https://github.com/element-hq/synapse/pull/16833, where we reduced the batching. The smaller batching can cause performance issues on busy servers and databases.
* Run `ANALYZE` after fiddling with stats (#16849)Erik Johnston2024-01-242-0/+18
| | | | | Introduced in #16833 Fixes #16844
* Speed up e2e device keys queries for bot accounts (#16841)Erik Johnston2024-01-231-11/+18
| | | | | | This helps with bot accounts with lots of non-e2e devices. The change is basically to change the order of the join for the case of using `INNER JOIN`
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-2399-0/+116
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Preparatory work for tweaking performance of auth chain lookups (#16833)Erik Johnston2024-01-234-27/+162
|
* Handle wildcard type filters properly (#14984)Mo Balaa2024-01-221-6/+17
|
* Optimize query for fetching to-device messages in `/sync` (#16805)Erik Johnston2024-01-111-77/+72
| | | | | | | | The current query supports passing in a list of users, which generates a query using `user_id = ANY(..)`. This is generates a less efficient query plan that is notably slower than a simple `user_id = ?` condition. Note: The new function is mostly a copy and paste and then a simplification of the existing function.
* Improve DB performance of calculating badge counts for push. (#16756)Erik Johnston2024-01-111-107/+146
| | | | | | | | | | | | | | | | The crux of the change is to try and make the queries simpler and pull out fewer rows. Before, there were quite a few joins against subqueries, which caused postgres to pull out more rows than necessary. Instead, let's simplify the query and do some of the filtering out in Python instead, letting Postgres do better optimizations now that it doesn't have to deal with joins against subqueries. Review note: this is a complete rewrite of the function, so not sure how useful the diff is. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Faster load recents for sync (#16783)Erik Johnston2024-01-101-1/+16
| | | This hopefully reduces the amount of state we need to keep in memory
* Reduce amount of state pulled out when querying federation hierachy (#16785)Erik Johnston2024-01-101-2/+46
| | | | | | | | | | | There are two changes here: 1. Only pull out the required state when handling the request. 2. Change the get filtered state return type to check that we're only querying state that was requested --------- Co-authored-by: reivilibre <oliverw@matrix.org>
* Split up deleting devices into batches (#16766)Erik Johnston2024-01-101-2/+6
| | | | Otherwise for users with large numbers of devices this can cause a lot of woe.
* Port `EventInternalMetadata` class to Rust (#16782)Erik Johnston2024-01-081-1/+1
| | | | | | | | | | | | | There are a couple of things we need to be careful of here: 1. The current python code does no validation when loading from the DB, so we need to be careful to ignore such errors (at least on jki.re there are some old events with internal metadata fields of the wrong type). 2. We want to be memory efficient, as we often have many hundreds of thousands of events in the cache at a time. --------- Co-authored-by: Quentin Gliech <quenting@element.io>
* Simplify internal metadata class. (#16762)Erik Johnston2024-01-051-33/+0
| | | | | | | | | We remove these fields as they're just duplicating data the event already stores, and (for reasons :shushing_face:) I'd like to simplify the class to only store simple types. I'm not entirely convinced that we shouldn't instead add helper methods to the event class to generate stream tokens, but I don't really think that's where they belong either
* Update book locationErik Johnston2023-12-132-2/+2
|
* Merge remote-tracking branch 'gitlab/clokep/license-license' into new_developErik Johnston2023-12-13394-1111/+7165
|\
| * Update license headersPatrick Cloke2023-11-21408-1111/+7431
| |
* | Revert postgres logical replication deltaas v1.98.0rc1David Robertson2023-12-05116-128/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts two commits: 0bb8e418a41c6f583ca9d705b400e37e2308a534 "Fix postgres schema after dropping old tables (#16730)" and 51e4e35653f98c3f61222fbdbdb1dcb8864f7fca "Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit one. This should allow use of Postgres logical replication. (take 2, now with no added deadlocks!) (#16658)" and also amends the changelog.
* | Fix postgres schema after dropping old tables (#16730)David Robertson2023-12-055-5/+0
| |
* | Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit ↵reivilibre2023-12-04121-0/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | one. This should allow use of Postgres logical replication. (take 2, now with no added deadlocks!) (#16658) * Add `ALTER TABLE ... REPLICA IDENTITY ...` for individual tables We can't combine them into one file as it makes it likely to hit a deadlock if Synapse is running, as it only takes one other transaction to access two tables in a different order to the schema delta. * Add notes * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Re-introduce REPLICA IDENTITY test --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* | Drop unused tables & unneeded access token ID for events. (#16522)Patrick Cloke2023-12-012-2/+26
| |
* | Speed up pruning of `user_ips` table (#16667)Erik Johnston2023-11-291-10/+7
| | | | | | Silly query planner
* | Remove old full schema dumps. (#16697)Patrick Cloke2023-11-2820-2962/+0
| | | | | | | | These are not useful and make it difficult to search for table definitions, etc.
* | Correctly read to-device stream pos on SQLite (#16682)David Robertson2023-11-241-12/+19
| |
* | Keep track of `user_ips` and `monthly_active_users` when delegating auth ↵David Robertson2023-11-231-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | (#16672) * Describe `insert_client_ip` * Pull out client_ips and MAU tracking to BaseAuth * Define HAS_AUTHLIB once in tests sick of copypasting * Track ips and token usage when delegating auth * Test that we track MAU and user_ips * Don't track `__oidc_admin`
* | Filter out auth chain queries that don't exist (#16552)Jason Little2023-11-221-0/+5
|/
* Speed up purge room by adding index (#16657)Erik Johnston2023-11-172-0/+25
| | | What it says on the tin
* Merge branch 'master' into developPatrick Cloke2023-11-171-2/+2
|\
| * Fix "'int' object is not iterable" error in set_device_id_for_pushers ↵Patrick Cloke2023-11-021-2/+2
| | | | | | | | | | | | background update (#16594) A regression from removing the cursor_to_dict call, adds back the wrapping into a tuple.
* | Revert "Fix test not detecting tables with missing primary keys and missing ↵Erik Johnston2023-11-162-110/+0
| | | | | | | | | | replica identities, then add more replica identities. (#16647)" (#16652) This reverts commit 830988ae72d63bbb67d2020a3f221664f3f456ee.
* | Revert "Add a Postgres `REPLICA IDENTITY` to tables that do not have an ↵Erik Johnston2023-11-162-118/+0
| | | | | | | | | | implicit one. This should allow use of Postgres logical replication. (#16456)" (#16651) This reverts commit 69afe3f7a0d89f3422ddbd3aa16bc9bbc01056eb.
* | Speed up deleting device messages (#16643)Erik Johnston2023-11-161-25/+81
| | | | | | Keeping track of a lower bound of stream ID where we've deleted everything below makes the queries much faster. Otherwise, every time we scan for rows to delete we'd re-scan across all the rows that have previously deleted (until the next table VACUUM).
* | Fix test not detecting tables with missing primary keys and missing replica ↵reivilibre2023-11-162-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | identities, then add more replica identities. (#16647) * Fix the CI query that did not detect all cases of missing primary keys * Add more missing REPLICA IDENTITY entries * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* | Add an Admin API to temporarily grant the ability to update an existing ↵David Robertson2023-11-152-0/+99
| | | | | | | | cross-signing key without UIA (#16634)
* | Asynchronous Uploads (#15503)Sumner Evans2023-11-151-2/+88
| | | | | | Support asynchronous uploads as defined in MSC2246.
* | Use full GitHub links instead of bare issue numbers. (#16637)Patrick Cloke2023-11-1510-12/+18
| |
* | Remove whole table locks on push rule add/delete (#16051)Nick Mills-Barrett2023-11-131-16/+27
| | | | | | | | The statements are already executed within a transaction thus a table level lock is unnecessary.
* | Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit ↵reivilibre2023-11-132-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | one. This should allow use of Postgres logical replication. (#16456) * Add Postgres replica identities to tables that don't have an implicit one Fixes #16224 * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Move the delta to version 83 as we missed the boat for 82 * Add a test that all tables have a REPLICA IDENTITY * Extend the test to include when indices are deleted * isort * black * Fully qualify `oid` as it is a 'hidden attribute' in Postgres 11 * Update tests/storage/test_database.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Add missed tables --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Use attempt_to_set_autocommit everywhere. (#16615)Patrick Cloke2023-11-093-12/+18
| | | | | | To avoid asserting the type of the database connection.
* | Use _invalidate_cache_and_stream_bulk in more places. (#16616)Patrick Cloke2023-11-096-46/+70
| | | | | | | | | | This takes advantage of the new bulk method in more places to invalidate caches for many keys at once (and then to stream that over replication).
* | Convert simple_select_one_txn and simple_select_one to return tuples. (#16612)Patrick Cloke2023-11-0919-241/+248
| |
* | Return attrs for more media repo APIs. (#16611)Patrick Cloke2023-11-091-40/+65
| |
* | Bulk-invalidate e2e cached queries after claiming keys (#16613)David Robertson2023-11-094-28/+131
| | | | | | | | Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* | Avoid updating the same rows multiple times with simple_update_many_txn. ↵Patrick Cloke2023-11-071-4/+1
| | | | | | | | | | | | (#16609) simple_update_many_txn had a bug in it which would cause each update to be applied twice.
* | Avoid executing no-op queries. (#16583)Patrick Cloke2023-11-075-19/+33
| | | | | | | | | | | | If simple_{insert,upsert,update}_many_txn is called without any data to modify then return instead of executing the query. This matches the behavior of simple_{select,delete}_many_txn.
* | More tests for the simple_* methods. (#16596)Patrick Cloke2023-11-071-9/+4
| | | | | | | | Expand tests for the simple_* database methods, additionally test against both PostgreSQL and SQLite variants.
* | Collect information for PushRuleEvaluator in parallel. (#16590)Patrick Cloke2023-11-061-19/+31
| | | | | | | | | | | | | | | | Fetch information needed for push rule evaluation in parallel. Ideally this would use query pipelining, but this is not available in psycopg2. Due to the database thread pool this may result in little to no parallelization.
* | Simplify event persistence code (#16584)Patrick Cloke2023-11-032-312/+324
| | | | | | | | | | | | | | | | | | | | | | The event persistence code used to handle multiple rooms at a time, but was simplified to only ever be called with a single room at a time (different rooms are now handled in parallel). The code is still generic to multiple rooms causing a lot of work that is unnecessary (e.g. unnecessary loops, and partitioning data by room). This strips out the ability to handle multiple rooms at once, greatly simplifying the code.
* | Use simple_select_many_txn in event persistance code. (#16585)Patrick Cloke2023-11-021-5/+11
| | | | | | | | | | Just to standardize on the normal helpers, it might also have a slight perf improvement on PostgreSQL which will now use `ANY (?)` instead of `IN (?, ?, ...)`.
* | Remove remaining usage of cursor_to_dict. (#16564)Patrick Cloke2023-10-317-91/+217
|/
* Claim local one-time-keys in bulk (#16565)David Robertson2023-10-301-114/+139
| | | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Claim fallback keys in bulk (#16570)David Robertson2023-10-302-0/+70
|
* Ensure local invited & knocking users leave before purge. (#16559)Patrick Cloke2023-10-271-0/+16
| | | | | This is mostly useful for federated rooms where some users would get stuck in the invite or knock state when the room was purged from their homeserver.
* Remove more usages of cursor_to_dict. (#16551)Patrick Cloke2023-10-2615-104/+133
| | | Mostly to improve type safety.
* Convert simple_select_list and simple_select_list_txn to return lists of ↵Patrick Cloke2023-10-2619-263/+343
| | | | | tuples (#16505) This should use fewer allocations and improves type hints.
* Allow multiple workers to write to receipts stream. (#16432)Erik Johnston2023-10-253-41/+128
| | | Fixes #16417
* Fix bug where a new writer advances their token too quickly (#16473)Erik Johnston2023-10-231-1/+67
| | | | | | | | | | | | | | | | | | | * Fix bug where a new writer advances their token too quickly When starting a new writer (for e.g. persisting events), the `MultiWriterIdGenerator` doesn't have a minimum token for it as there are no rows matching that new writer in the DB. This results in the the first stream ID it acquired being announced as persisted *before* it actually finishes persisting, if another writer gets and persists a subsequent stream ID. This is due to the logic of setting the minimum persisted position to the minimum known position of across all writers, and the new writer starts off not being considered. * Fix sending out POSITIONs when our token advances without update Broke in #14820 * For replication HTTP requests, only wait for minimal position
* Fix bug that could cause a `/sync` to tightloop with sqlite after restart ↵Erik Johnston2023-10-231-1/+4
| | | | | (#16540) This could happen if the last rows in the account data stream were inserted into `account_data`. After a restart the max account ID would be calculated without looking at the `account_data` table, and so have an old ID.
* Remove the last reference to event_txn_id. (#16521)Patrick Cloke2023-10-232-7/+4
| | | | This table was no longer used, except for a background process which purged old entries in it.
* Mark sync as limited if there is a gap in the timeline (#16485)Erik Johnston2023-10-193-25/+121
| | | | | | | | This splits thinsg into two queries, but most of the time we won't have new event backwards extremities so this shouldn't actually add an extra RTT for the majority of cases. Note this removes the check for events with no prev events, but that was part of MSC2716 work that has since been removed.
* Avoid sending massive replication updates when purging a room. (#16510)Patrick Cloke2023-10-181-0/+8
|
* Improve performance of delete device messages query (#16492)Mathieu Velten2023-10-181-7/+8
|
* Convert DeviceLastConnectionInfo to attrs. (#16507)Patrick Cloke2023-10-171-20/+26
| | | To improve type safety & memory usage.
* Convert state delta processing from a dict to attrs. (#16469)Patrick Cloke2023-10-162-30/+36
| | | For improved type checking & memory usage.
* Remove useless async job to delete device messages on sync (#16491)Mathieu Velten2023-10-161-2/+3
|
* Revert "Drop unused tables & unneeded access token ID for events. (#16268)" ↵Patrick Cloke2023-10-122-26/+2
| | | | | | | | (#16465) This reverts commit cabd57746004fe2dacc11aa8d373854a3d25e306. There are additional usages of these tables which need to be removed first.
* Convert user_get_threepids response to attrs. (#16468)Patrick Cloke2023-10-111-5/+14
| | | This improves type annotations by not having a dictionary of Any values.
* Convert simple_select_many_batch, simple_select_many_txn to tuples. (#16444)Patrick Cloke2023-10-1121-416/+601
|
* Inline simple_search_list/simple_search_list_txn. (#16434)Patrick Cloke2023-10-102-72/+36
| | | | This only has a single use and is over abstracted. Inline it so that we can improve type hints.
* Add DB indices to speed up purging rooms (#16457)David Robertson2023-10-103-0/+34
|
* Disable statement timeout whilst purging rooms (#16455)reivilibre2023-10-091-0/+5
| | | | | | | | | | | | | * Disable statement timeout whilst purging rooms * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Note the introduction version --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Convert simple_select_list_paginate_txn to return tuples. (#16433)Patrick Cloke2023-10-063-33/+58
|
* Return ThumbnailInfo in more places (#16438)Patrick Cloke2023-10-061-5/+25
| | | | Improves type hints by using concrete types instead of dictionaries.
* Drop unused tables & unneeded access token ID for events. (#16268)Patrick Cloke2023-10-062-2/+26
| | | | Drop the event_txn_id table and the tables related to MSC2716, which is no longer supported in Synapse.
* Remove unused method. (#16435)Patrick Cloke2023-10-051-20/+0
|
* Remove manys calls to cursor_to_dict (#16431)Patrick Cloke2023-10-0513-226/+317
| | | | | | | | | | This avoids calling cursor_to_dict and then immediately unpacking the values in the dict for other users. By not creating the intermediate dictionary we can avoid allocating the dictionary and strings for the keys, which should generally be more performant. Additionally this improves type hints by avoid Dict[str, Any] dictionaries coming out of the database layer.
* Factor out `MultiWriter` token from `RoomStreamToken` (#16427)Erik Johnston2023-10-051-9/+13
|
* Some refactors around receipts stream (#16426)Erik Johnston2023-10-042-5/+3
|
* mypy plugin to check `@cached` return types (#14911)David Robertson2023-10-024-10/+15
| | | | | | | | Co-authored-by: David Robertson <davidr@element.io> Co-authored-by: Patrick Cloke <patrickc@matrix.org> Co-authored-by: Erik Johnston <erik@matrix.org> Assert that the return type of callables wrapped in @cached and @cachedList are cachable (aka immutable).
* Add a cache around server ACL checking (#16360)Patrick Cloke2023-09-261-0/+59
| | | | | * Pre-compiles the server ACLs onto an object per room and invalidates them when new events come in. * Converts the server ACL checking into Rust.
* Implement MSC4028: push all encrypted events. (#16361)Patrick Cloke2023-09-261-0/+1
| | | | This unstable push rule is implemented behind an experimental configuration flag.
* Improve comments in StateGroupBackgroundUpdateStore. (#16383)Patrick Cloke2023-09-251-2/+16
|
* Bump types-psycopg2 from 2.9.21.11 to 2.9.21.14 (#16381)dependabot[bot]2023-09-252-29/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Bump types-psycopg2 from 2.9.21.11 to 2.9.21.14 Bumps [types-psycopg2](https://github.com/python/typeshed) from 2.9.21.11 to 2.9.21.14. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-psycopg2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Relax the annotation of Cursor.description See https://github.com/matrix-org/synapse/pull/16343#issuecomment-1726083384 for rationale. * Changelog * Changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: David Robertson <davidr@element.io>
* Add support for pydantic v2 via pydantic.v1 compat module (#16332)Maxwell G2023-09-251-1/+6
| | | While maintaining support with pydantic v1.
* Convert more cached return values to immutable types (#16356)Patrick Cloke2023-09-204-9/+11
|
* Return immutable objects for cachedList decorators (#16350)Patrick Cloke2023-09-1913-51/+80
|
* Bump ruff from 0.0.286 to 0.0.290 (#16342)dependabot[bot]2023-09-182-13/+2
| | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Filter locked users in the admin API (#16328)Hanadi2023-09-182-1/+7
| | | | Co-authored-by: Hanadi Tamimi <hanadi.tamimi@sdui.de>
* Make cached account data/tags/admin types immutable (#16325)Patrick Cloke2023-09-183-14/+13
|
* Return an immutable value from get_latest_event_ids_in_room. (#16326)Patrick Cloke2023-09-183-9/+10
|
* Convert `_insert_graph_receipts_txn` to `simple_upsert` (#16299)Jason Little2023-09-152-14/+12
|
* Some minor performance fixes for task schedular (#16313)Erik Johnston2023-09-142-0/+22
|
* Refactor `get_user_by_id` (#16316)Erik Johnston2023-09-142-54/+33
|
* Fix using dehydrated devices (MSC2697) & refresh tokens (#16288)Hanadi2023-09-131-0/+20
| | | | | Refresh tokens were not correctly moved to the rehydrated device (similar to how the access token is currently handled). This resulted in invalid refresh tokens after rehydration.
* Use StrCollection in additional places. (#16301)Patrick Cloke2023-09-131-2/+2
|
* Stop purging tables which are slated for removal. (#16273)Patrick Cloke2023-09-122-5/+5
|
* Refactor storing of server keys (#16261)Erik Johnston2023-09-121-147/+72
|
* Improve type hints for attrs classes (#16276)David Robertson2023-09-081-5/+3
|
* Update ruff config (#16283)Patrick Cloke2023-09-081-2/+0
| | | Enable additional checks & clean-up unneeded configuration.
* Log values at DEBUG level with execute_values (#16281)David Robertson2023-09-081-2/+3
|
* Recheck if remote device is cached before requesting it (#16252)Erik Johnston2023-09-071-9/+17
| | | | This fixes a bug where we could get stuck re-requesting the device over replication again and again.
* Add `/notifications` endpoint to workers (#16265)Erik Johnston2023-09-071-36/+36
|
* Merge remote-tracking branch 'origin/release-v1.92' into developPatrick Cloke2023-09-062-22/+0
|\
| * Merge remote-tracking branch 'origin/release-v1.91' into release-v1.92Patrick Cloke2023-09-062-22/+0
| |\
| | * Revert MSC3861 introspection cache, admin impersonation and account lock ↵Quentin Gliech2023-09-062-22/+0
| | | | | | | | | | | | (#16258)
* | | Delete device messages asynchronously and in staged batches (#16240)Mathieu Velten2023-09-067-21/+37
| | |
* | | Fix appservices being unable to handle to_device messages for multiple users ↵Will Hunt2023-09-051-1/+1
| | | | | | | | | | | | (#16251)
* | | Fix bug where we kept re-requesting a remote server's key repeatedly. (#16257)Erik Johnston2023-09-051-6/+11
|/ / | | | | | | | | * Correctly handle multiple rows per server/key * Newsfile
* | Don't wake up destination transaction queue if they're not due for retry. ↵Erik Johnston2023-09-041-3/+23
| | | | | | | | (#16223)
* | Add last_seen_ts to the admin users API (#16218)Mathieu Velten2023-09-043-2/+12
| |
* | Log the details of background update failures (#16212)David Robertson2023-09-011-2/+2
| |
* | Fix rare bug that broke looping calls (#16210)Erik Johnston2023-08-301-14/+22
| | | | | | | | | | | | | | | | | | | | * Fix rare bug that broke looping calls We can't interact with the reactor from the main thread via looping call. Introduced in v1.90.0 / #15791. * Newsfile
* | Stop writing to the event_txn_id table (#16175)Patrick Cloke2023-08-303-71/+21
| |
* | Bump mypy-zope & mypy. (#16188)Patrick Cloke2023-08-291-1/+16
| |
* | Bump ruff from 0.0.277 to 0.0.286 (#16198)dependabot[bot]2023-08-291-3/+3
| | | | | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* | Stabilize support for MSC3958 (suppress notifications from edits). (#16113)Patrick Cloke2023-08-231-1/+0
|/
* Fix rare deadlock when using read/write locks (#16169) release-v1.91.0Erik Johnston2023-08-232-37/+71
|
* Filter out unwanted user_agents from udv. (#16124)Neil Johnson2023-08-231-0/+5
|
* Fix rare deadlock when using read/write locks (#16133)Erik Johnston2023-08-231-0/+37
|
* Reduce DB contention on worker locks (#16160)Erik Johnston2023-08-231-0/+37
|
* Always update `retry_last_ts` (#16164)Erik Johnston2023-08-231-3/+3
|
* Task scheduler: mark task as active if we are scheduling ASAP (#16165)Mathieu Velten2023-08-231-1/+1
|
* Properly update retry_last_ts when hitting the maximum retry interval (#16156)DeepBlueV7.X2023-08-231-1/+3
| | | | | | | | | | | | | | | | | | | | | * Properly update retry_last_ts when hitting the maximum retry interval This was broken in 1.87 when the maximum retry interval got changed from almost infinite to a week (and made configurable). fixes #16101 Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> * Add changelog * Change fix + add test * Add comment --------- Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> Co-authored-by: Mathieu Velten <mathieuv@matrix.org>
* Increase perf of read/write locks (#16149)Erik Johnston2023-08-231-0/+30
| | | We do this by marking the tables as `UNLOGGED` in PostgreSQL.
* Add an admin endpoint to allow authorizing server to signal token ↵Shay2023-08-222-0/+22
| | | | revocations (#16125)
* Implements a task scheduler for resumable potentially long running tasks ↵Mathieu Velten2023-08-214-0/+233
| | | | (#15891)
* Speed up state res in rare case we don't have all events (#16116)Erik Johnston2023-08-181-23/+161
| | | | | | | If we don't have all the auth events in a room then not all state events will have a chain cover index. Even so, we can still use the chain cover index on the events that do have it, rather than bailing and using the slower functions. This situation should not arise for newly persisted rooms, as we check we have the full auth chain for each event, but can happen for existing rooms. c.f. #15245
* Allow filtering for admins in the list accounts admin API (#16114)Alexander Fechler2023-08-181-0/+10
|
* Add cache to `get_server_keys_json_for_remote` (#16123)Erik Johnston2023-08-182-44/+95
|
* Fix database performance of read/write worker locks (#16061)Erik Johnston2023-08-171-52/+35
| | | | | | | We were seeing serialization errors when taking out multiple read locks. The transactions were retried, so isn't causing any failures. Introduced in #15782.
* Override global statement timeout when creating indexes in Postgres (#16085)Shay2023-08-171-0/+12
|
* Rename pagination&purge locks and add comments explaining them (#16112)Mathieu Velten2023-08-161-2/+2
|
* Run pyupgrade for python 3.7 & 3.8. (#16110)Patrick Cloke2023-08-155-8/+14
|
* Implements admin API to lock an user (MSC3939) (#15870)Mathieu Velten2023-08-103-5/+84
|
* Support MSC3814: Dehydrated Devices Part 2 (#16010)Shay2023-08-082-59/+162
|
* Remove old rows from the `cache_invalidation_stream_by_instance` table ↵reivilibre2023-08-081-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | automatically. (This table is not used when Synapse is configured to use SQLite.) (#15868) * Add a cache invalidation clean-up task * Run the cache invalidation stream clean-up on the background worker * Tune down * call_later is in millis! * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * fixup! Add a cache invalidation clean-up task * Update synapse/storage/databases/main/cache.py Co-authored-by: Eric Eastwood <erice@element.io> * Update synapse/storage/databases/main/cache.py Co-authored-by: Eric Eastwood <erice@element.io> * MILLISEC -> MS * Expand on comment * Move and tweak comment about Postgres * Use `wrap_as_background_process` --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Eric Eastwood <erice@element.io>
* Stabilize support for MSC3970: updated transaction semantics (scope to ↵Patrick Cloke2023-08-042-10/+10
| | | | | | | `device_id`) (#15629) For now this maintains compatible with old Synapses by falling back to using transaction semantics on a per-access token. A future version of Synapse will drop support for this.
* Add ability to wait for locks and add locks to purge history / room deletion ↵Erik Johnston2023-07-312-75/+142
| | | | | (#15791) c.f. #13476
* Inline SQL queries using boolean parameters (#15525)Anshul Madnawat2023-07-267-25/+23
| | | | SQLite now supports TRUE and FALSE constants, simplify some queries by inlining those instead of passing them as arguments.
* Bump DB version to 79 since synapse v1.88 was already there (#15998)Mathieu Velten2023-07-266-16/+21
|
* Actually stop reading from column `user_id` of tables `profiles` (#15955)Shay2023-07-233-11/+10
|
* Speed up updating state in large rooms (#15971)Erik Johnston2023-07-202-124/+135
| | | This should speed up updating state in rooms with lots of state.
* Fix bad merge of #15933 (#15958)Erik Johnston2023-07-192-0/+0
| | | This was because we reverted the bump of the schema version, so we were not applying the new deltas.
* Fix race in triggers for read/write locks. (#15933)Erik Johnston2023-07-194-98/+134
|
* Fix background schema updates failing over a large upgrade gap (#15887)Shay2023-07-181-0/+70
|
* Merge branch 'master' into developOlivier Wilkinson (reivilibre)2023-07-187-122/+16
|\
| * Revert "Stop writing to column `user_id` of tables `profiles` and ↵Shay2023-07-187-122/+16
| | | | | | | | | | | | | | | | | | `user_filters`. (#15953) * Revert "Stop writing to column `user_id` of tables `profiles` and `user_filters` (#15787)" This reverts commit f25b0f88081bb436bef914983cff7087b54eba5f. * newsfragement
* | Support room version 11 (#15912)Patrick Cloke2023-07-181-1/+1
| | | | | | | | | | And fix a bug in the implementation of the updated redaction format (MSC2174) where the top-level redacts field was not properly added for backwards-compatibility.
* | Mark get_user_in_directory private since only used in tests (#15884)Mathieu Velten2023-07-121-8/+1
|/
* Fix downgrading to previous version of Synapse (#15907)Erik Johnston2023-07-103-4/+17
| | | We do this by marking the constraint as deferrable.
* Stop writing to column `user_id` of tables `profiles` and `user_filters` ↵Shay2023-07-077-16/+122
| | | | (#15787)
* Add basic read/write lock (#15782)Erik Johnston2023-07-053-56/+439
|
* Add tracing to media `/upload` endpoint (#15850)Eric Eastwood2023-07-051-0/+5
| | | Add tracing instrumentation to media `/upload` code paths to investigate https://github.com/matrix-org/synapse/issues/15841
* Fix could not serialize access due to concurrent `DELETE` from ↵Jason Little2023-07-051-1/+6
| | | | | | | presence_stream (#15826) * Change update_presence to have a isolation level of READ_COMMITTED * changelog
* Add foreign key constraint to `event_forward_extremities`. (#15751)Erik Johnston2023-07-055-7/+438
|
* Add not_user_type param to the list accounts admin API (#15844)Michael Weimann2023-07-041-0/+37
| | | Signed-off-by: Michael Weimann <michaelw@element.io>
* devices: use combined ANY clause for faster cleanup (#15861)pacien2023-07-031-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Old device entries for the same user were being removed in individual SQL commands, making the batch take way longer than necessary. This combines the commands into a single one with a IN/ANY clause. Example of log entry before the change, regularly observed with "log_min_duration_statement = 10000" in PostgreSQL's config: LOG: duration: 42538.282 ms statement: DELETE FROM device_lists_stream WHERE user_id = '@someone' AND device_id = 'someid1' AND stream_id < 123456789 ; DELETE FROM device_lists_stream WHERE user_id = '@someone' AND device_id = 'someid2' AND stream_id < 123456789 ; [repeated for each device ID of that user, potentially a lot...] With the patch applied on my instance for the past couple of days, I no longer notice overly long statements of that particular kind. Signed-off-by: pacien <pacien.trangirard@pacien.net>
* Add a timeout that aborts any Postgres statement taking more than 1 hour. ↵reivilibre2023-07-031-0/+13
| | | | | | | | | | | | | (#15853) * Add a timeout to Postgres statements * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Fix sqlite `user_filters` upgrade (#15817)Shay2023-06-273-3/+91
|
* Fix forgotten rooms missing in initial sync (#15815)Nicolas Werner2023-06-211-0/+13
| | | | | | | | If you leave a room and forget it, then rejoin it, the room would be missing from the next initial sync. fixes #13262 Signed-off-by: Nicolas Werner <n.werner@famedly.com>
* Remove experimental MSC2716 implementation to incrementally import history ↵Eric Eastwood2023-06-164-384/+1
| | | | | | | | | | | | into existing rooms (#15748) Context for why we're removing the implementation: - https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1487441010 - https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1504262734 Anyone wanting to continue MSC2716, should also address these leftover tasks: https://github.com/matrix-org/synapse/issues/10737 Closes https://github.com/matrix-org/synapse/issues/10737 in the fact that it is not longer necessary to track those things.
* Don't always lock "user_ips" table when performing non-native upsert (#15788)Andrew Morgan2023-06-161-1/+1
|
* Prefill events after invalidate not before when persisting events (#15758)Jason Little2023-06-142-4/+13
| | | | | Fixes #15757
* Replace `EventContext` fields `prev_group` and `delta_ids` with field ↵Shay2023-06-131-3/+2
| | | | `state_group_deltas` (#15233)
* Clear event caches when we purge history (#15609)Erik Johnston2023-06-084-5/+177
| | | | | | | This should help a little with #13476 --------- Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Quick & dirty metric for background update status (#15740)David Robertson2023-06-072-1/+37
| | | | | | | | | | | | | | | * Quick & dirty metric for background update status * Changelog * Remove debug Co-authored-by: Mathieu Velten <mathieuv@matrix.org> * Actually write to _aborted --------- Co-authored-by: Mathieu Velten <mathieuv@matrix.org>
* Remove superfluous `room_memberships` join from background update (#15733)Eric Eastwood2023-06-071-1/+0
| | | Spawning from https://github.com/matrix-org/synapse/pull/15731
* Merge branch 'master' into developErik Johnston2023-06-071-1/+21
|\
| * Fix schema delta error in 1.85 (#15739)Erik Johnston2023-06-071-2/+14
| | | | | | | | Some users seem to have multiple rows per user / room with a null thread ID, which we need to handle.
| * Fix schema delta error in 1.85 (#15738)Erik Johnston2023-06-071-0/+8
| | | | | | | | | | | | | | | | There appears to be a race where you can end up with entries in `event_push_summary` with both a `NULL` and `main` thread ID. Fixes #15736 Introduced in #15597
* | No need for the extra join since `membership` is built-in to ↵Eric Eastwood2023-06-061-4/+3
| | | | | | | | | | | | | | `current_state_events` (#15731) This helps with the upstream `is_host_joined()` and `is_host_invited()` functions. `membership` was added to `current_state_events` in https://github.com/matrix-org/synapse/pull/5706 and forced in https://github.com/matrix-org/synapse/pull/13745
* | Improve performance of user directory search (#15729)Shay2023-06-061-4/+8
| |
* | Stabilize support for MSC3952: Intentional mentions. (#15520)Patrick Cloke2023-06-061-1/+0
| |