summary refs log tree commit diff
path: root/synapse/storage (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Prevent breaking old sqlite's when media retention is enabled (#12977)Andrew Morgan2022-06-071-1/+1
|
* Prevent local quarantined media from being claimed by media retention (#12972)Andrew Morgan2022-06-071-5/+63
|
* Remove remaining pieces of groups code. (#12966)Patrick Cloke2022-06-064-125/+3
| | | | | * Remove an unused stream ID generator. * Remove the now unused remote profile cache.
* Reduce state pulled from DB due to sending typing and receipts over ↵Erik Johnston2022-06-063-0/+46
| | | | | federation (#12964) Reducing the amount of state we pull from the DB is useful as fetching state is expensive in terms of DB, CPU and memory.
* Reduce the amount of state we pull from the DB (#12811)Erik Johnston2022-06-061-0/+27
|
* Remove groups code from synapse_port_db. (#12899)Patrick Cloke2022-06-031-7/+2
|
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-019-39/+207
|
* Remove remaining bits of groups code. (#12936)Patrick Cloke2022-06-011-4/+0
| | | | | | * Update worker docs to remove group endpoints. * Removes an unused parameter to `ApplicationService`. * Break dependency between media repo and groups. * Avoid copying `m.room.related_groups` state events during room upgrades.
* Fix 404 on `/sync` when the last event is a redaction of an unknown/purged ↵Richard van der Hoff2022-06-012-10/+14
| | | | | | | | | | | event (#12905) Currently, we try to pull the event corresponding to a sync token from the database. However, when we fetch redaction events, we check the target of that redaction (because we aren't allowed to send redactions to clients without validating them). So, if the sync token points to a redaction of an event that we don't have, we have a problem. It turns out we don't really need that event, and can just work with its ID and metadata, which sidesteps the whole problem.
* Remove most groups datastore code. (#12895)Patrick Cloke2022-05-311-1394/+4
| | | | The remaining piece is a background update that is needed for backwards compatibility.
* Faster room joins: Resume state re-syncing after a Synapse restart (#12813)Sean Quah2022-05-311-0/+27
| | | | Signed-off-by: Sean Quah <seanq@matrix.org>
* Reduce DB load of /sync when using presence (#12885)Erik Johnston2022-05-311-27/+48
| | | While the query was fast, we were calling it *a lot*.
* Stop reading from `event_edges.room_id`. (#12914)Richard van der Hoff2022-05-313-24/+21
| | | event_edges.room_id is implied by the event id, so there is no need to join on the room id.
* Rename storage classes (#12913)Erik Johnston2022-05-316-350/+406
|
* Add a migration step to cleanup potential leftovers of bug 11833 (#12784)Mathieu Velten2022-05-301-0/+19
| | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Fix invite notifications for users without pushers (#12840)DeepBlueV7.X2022-05-301-6/+0
| | | | Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> Co-authored-by: Brendan Abolivier <github@brendanabolivier.com>
* Fix `get_metadata_for_events` (#12904)Richard van der Hoff2022-05-301-2/+2
| | | | This method was introduced in #12852. It is using the `state_key` column from the `events` table, which is not (yet) reliable (see #11496).
* Mutual rooms: Remove dependency on user directory (#12836)Jonathan de Jong2022-05-302-43/+24
|
* LockStore: fix acquiring a lock via `LockStore.try_acquire_lock` (#12832)Sumner Evans2022-05-301-1/+18
| | | Signed-off-by: Sumner Evans <sumner@beeper.com>
* Add a background job to automatically delete stale devices (#12855)Brendan Abolivier2022-05-271-0/+39
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Clean-up some receipts code (#12888)Patrick Cloke2022-05-271-42/+47
| | | | | * Properly marks private methods as private. * Adds missing docstrings. * Rework inline methods.
* Additional constants for EDU types. (#12884)Patrick Cloke2022-05-272-6/+7
| | | Instead of hard-coding strings in many places.
* Add storage and module API methods to get monthly active users and their ↵Matt C2022-05-271-0/+45
| | | | appservices (#12838)
* Fix room deletion (#12889)Richard van der Hoff2022-05-271-9/+10
| | | | | | | | | * Fix room deletion ae7858f broke room deletion by attempting to delete the entry from `rooms` before the tables that reference it. * faster_joins: remove database rows on purge
* Refactor have_seen_events to reduce OOMs (#12886)Richard van der Hoff2022-05-271-18/+24
| | | | | My server is currently OOMing in the middle of have_seen_events, so let's try to fix that.
* Fix ambiguous column name that would prevent use of MSC2716 History Import ↵reivilibre2022-05-261-1/+1
| | | | when using Postgres as a database. (#12843)
* Avoid attempting to delete push actions for remote users. (#12879)Patrick Cloke2022-05-263-3/+6
| | | | Remote users will never have push actions, so we can avoid a database round-trip/transaction completely.
* Pull out less state when handling gaps mk2 (#12852)Erik Johnston2022-05-261-0/+59
|
* Fix caching behavior for relations push rules. (#12859)Patrick Cloke2022-05-251-2/+3
| | | | | By always returning all requested values from the function wrapped by cachedList. Otherwise implicit None values get added into the cache, which are unexpected.
* Misc clean-up of push rules datastore (#12856)Patrick Cloke2022-05-251-11/+5
|
* Fixes to MSC3787 implementation (#12858)David Robertson2022-05-241-18/+17
|
* Experimental support for MSC3772 (#12740)Patrick Cloke2022-05-243-0/+66
| | | | | | | | | | Implements the following behind an experimental configuration flag: * A new push rule kind for mutually related events. * A new default push rule (`.m.rule.thread_reply`) under an unstable prefix. This is missing part of MSC3772: * The `.m.rule.thread_reply_to_me` push rule, this depends on MSC3664 / #11804.
* Prevent expired events from being filtered out when retention is disabled ↵Brendan Abolivier2022-05-231-20/+25
| | | | | | (#12611) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix media thumbnails being unusable before the index had been added in the ↵reivilibre2022-05-231-0/+2
| | | | background. (#12823)
* Update EventContext `get_current_event_ids` and `get_prev_event_ids` to ↵Shay2022-05-201-2/+5
| | | | accept state filters and update calls where possible (#12791)
* Add a unique index to `state_group_edges` to prevent duplicates being ↵reivilibre2022-05-193-0/+48
| | | | accidentally introduced and the consequential impact to performance. (#12687)
* Skip waiting for full state if a StateFilter does not require it (#12498)Richard van der Hoff2022-05-181-4/+59
| | | | | If `StateFilter` specifies a state set which we will have regardless of state-syncing, then we may as well return it immediately.
* Refactor `resolve_state_groups_for_events` to not pull out full state when ↵Shay2022-05-182-7/+7
| | | | no state resolution happens. (#12775)
* Add some type hints to `event_federation` datastore (#12753)Dirk Klimpel2022-05-181-64/+123
| | | Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* Do not keep going if there are 5 back-to-back background update failures. ↵reivilibre2022-05-181-0/+8
| | | | (#12781)
* Discard null-containing strings before updating the user directory (#12762)David Robertson2022-05-182-8/+5
|
* Move methods that call add_push_rule to PushRuleStore (#12772)Adam2022-05-181-51/+51
| | | Signed-off-by: Adam Roddick <ajroddick@tuta.io>
* Delete events from federation_inbound_events_staging table on purge (#12770)Mathieu Velten2022-05-171-0/+1
|
* allow `on_invalidate=None` in `@cached` methods (#12769)David Robertson2022-05-171-1/+2
|
* Add some type hints to datastore (#12717)Dirk Klimpel2022-05-174-145/+229
|
* Remove code which updates `application_services_state.last_txn` (#12680)Richard van der Hoff2022-05-172-24/+28
| | | | This column is unused as of #12209, so let's stop writing to it.
* Merge branch 'master' into developDavid Robertson2022-05-171-1/+1
|\
| * Fix query performance for /sync (#12745)Erik Johnston2022-05-161-1/+1
| |
* | Add index to cache invalidations (#12747)Erik Johnston2022-05-172-0/+26
| | | | | | | | | | For workers that rarely write to the cache the `get_all_updated_caches` query can become expensive if the worker falls behind when reading the cache.
* | Track in memory events using weakrefs (#10533)Erik Johnston2022-05-171-2/+33
| |
* | Tidy up and type-hint the database engine modules (#12734)David Robertson2022-05-175-94/+178
| | | | | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* | Add `StreamKeyType` class and replace string literals with constants (#12567)Andrew Morgan2022-05-162-4/+6
| |
* | Merge tag 'v1.59.0rc2' into developDavid Robertson2022-05-161-8/+11
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Synapse 1.59.0rc2 (2022-05-16) ============================== Synapse 1.59 makes several changes that server administrators should be aware of: - Device name lookup over federation is now disabled by default. ([\#12616](https://github.com/matrix-org/synapse/issues/12616)) - The `synapse.app.appservice` and `synapse.app.user_dir` worker application types are now deprecated. ([\#12452](https://github.com/matrix-org/synapse/issues/12452), [\#12654](https://github.com/matrix-org/synapse/issues/12654)) See [the upgrade notes](https://github.com/matrix-org/synapse/blob/develop/docs/upgrade.md#upgrading-to-v1590) for more details. Additionally, this release removes the non-standard `m.login.jwt` login type from Synapse. It can be replaced with `org.matrix.login.jwt` for identical behaviour. This is only used if `jwt_config.enabled` is set to `true` in the configuration. ([\#12597](https://github.com/matrix-org/synapse/issues/12597)) Bugfixes -------- - Fix a bug introduced in Synapse 1.58.0 where `/sync` would fail if the most recent event in a room was rejected. ([\#12729](https://github.com/matrix-org/synapse/issues/12729))
| * Fix bug /sync returning 404 (#12729)Erik Johnston2022-05-161-8/+11
| | | | | | | | | | * Fix bug /sync returning 404 Fixes #12571
* | Consolidate logic for parsing relations. (#12693)Patrick Cloke2022-05-161-28/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | Parse the `m.relates_to` event content field (which describes relations) in a single place, this is used during: * Event persistence. * Validation of the Client-Server API. * Fetching bundled aggregations. * Processing of push rules. Each of these separately implement the logic and each made slightly different assumptions about what was valid. Some had minor / potential bugs.
* | Another batch of type annotations (#12726)David Robertson2022-05-131-5/+14
| |
* | Reduce the number of "untyped defs" (#12716)David Robertson2022-05-127-39/+76
| |
* | Fix `/messages` throwing a 500 when querying for non-existent room (#12683)Eric Eastwood2022-05-101-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/12678 Complement test added: https://github.com/matrix-org/complement/pull/369 **Before:** 500 internal server error **After:** According to the [spec](https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3roomsroomidmessages), calling `/messages` against a non-existent `room_id` should throw a 403 forbidden (since you're not part of the room). This also matches the behavior before https://github.com/matrix-org/synapse/pull/12370 which regressed Synapse to the 500 behavior. ```json { "errcode": "M_FORBIDDEN", "error": "User @test:my.synapse.server not in room !dne:my.synapse.server, and room previews are disabled" } ```
* | Refactor `EventContext` (#12689)Erik Johnston2022-05-102-41/+7
| | | | | | | | | | | | | | | | | | | | Refactor how the `EventContext` class works, with the intention of reducing the amount of state we fetch from the DB during event processing. The idea here is to get rid of the cached `current_state_ids` and `prev_state_ids` that live in the `EventContext`, and instead defer straight to the database (and its caching). One change that may have a noticeable effect is that we now no longer prefill the `get_current_state_ids` cache on a state change. However, that query is relatively light, since its just a case of reading a table from the DB (unlike fetching state at an event which is more heavyweight). For deployments with workers this cache isn't even used. Part of #12684
* | Add some type hints to datastore. (#12477)Dirk Klimpel2022-05-102-70/+119
| |
* | Stop writing to `event_reference_hashes` (#12679)Richard van der Hoff2022-05-103-29/+4
|/ | | | | This table is never read, since #11794. We stop writing to it; in future we can drop it altogether.
* Implement MSC3786: Add a default push rule to ignore m.room.server_acl ↵Šimon Brandner2022-05-101-11/+37
| | | | | | events (#12601) Fixes vector-im/element-web#20788 Implements matrix-org/matrix-spec-proposals#3786
* Use `ParamSpec` in a few places (#12667)David Robertson2022-05-092-13/+26
|
* Use `Concatenate` to annotate `do_execute` (#12666)David Robertson2022-05-091-5/+14
|
* Remove unused receipt datastore methods. (#12632)Patrick Cloke2022-05-051-54/+0
| | | The last usage was removed in 5a1dd297c3ce105a7f516d9d9fe87b94b9d356c8 (#8059).
* Add `mau_appservice_trial_days` config (#12619)Will Hunt2022-05-041-2/+6
| | | | | | | | | | | | | | | | | | | | | * Add mau_appservice_trial_days * Add a test * Tweaks * changelog * Ensure we sync after the delay * Fix types * Add config statement * Fix test * Reinstate logging that got removed * Fix feature name
* Implement changes to MSC2285 (hidden read receipts) (#12168)Šimon Brandner2022-05-041-32/+110
| | | | | * Changes hidden read receipts to be a separate receipt type (instead of a field on `m.read`). * Updates the `/receipts` endpoint to accept `m.fully_read`.
* Include bundled aggregations for the latest event in a thread. (#12273)Patrick Cloke2022-05-041-8/+3
| | | | | | The `latest_event` field of the bundled aggregations for `m.thread` relations did not include bundled aggregations itself. This resulted in clients needing to immediately request the event from the server (and thus making it useless that the latest event itself was serialized instead of just including an event ID).
* remove constantly lib use and switch to enums. (#12624)andrew do2022-05-044-28/+28
|
* Add a consistency check on events read from the database (#12620)Richard van der Hoff2022-05-031-0/+12
| | | | | | | I've seen a few errors which can only plausibly be explained by the calculated event id for an event being different from the ID of the event in the database. It should be cheap to check this, so let's do so and raise an exception.
* Fix race when persisting an event and deleting a room (#12594)Erik Johnston2022-05-032-2/+21
| | | | | This works by taking a row level lock on the `rooms` table at the start of both transactions, ensuring that they don't run at the same time. In the event persistence transaction we also check that there is an entry still in the `rooms` table. I can't figure out how to do this in SQLite. I was just going to lock the table, but it seems that we don't support that in SQLite either, so I'm *really* confused as to how we maintain integrity in SQLite when using `lock_table`....
* Improve the docstrings for the receipts store. (#12581)Patrick Cloke2022-04-281-5/+51
|
* Add a module API to allow modules to edit push rule actions (#12406)Brendan Abolivier2022-04-271-8/+7
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove unused `# type: ignore`s (#12531)David Robertson2022-04-272-5/+5
| | | | | | | | | | | | | | | | | | | | | | Over time we've begun to use newer versions of mypy, typeshed, stub packages---and of course we've improved our own annotations. This makes some type ignore comments no longer necessary. I have removed them. There was one exception: a module that imports `select.epoll`. The ignore is redundant on Linux, but I've kept it ignored for those of us who work on the source tree using not-Linux. (#11771) I'm more interested in the config line which enforces this. I want unused ignores to be reported, because I think it's useful feedback when annotating to know when you've fixed a problem you had to previously ignore. * Installing extras before typechecking Lacking an easy way to install all extras generically, let's bite the bullet and make install the hand-maintained `all` extra before typechecking. Now that https://github.com/matrix-org/backend-meta/pull/6 is merged to the release/v1 branch.
* Consistently use collections.abc.Mapping to check frozendict. (#12564)Patrick Cloke2022-04-271-3/+2
|
* Add some type hints to datastore (#12485)Dirk Klimpel2022-04-2711-84/+187
|
* Mark remote device list updates as already handled (#12557)Erik Johnston2022-04-261-1/+2
|
* Fix sending opentracing contexts to remote servers (#12555)Erik Johnston2022-04-261-1/+11
|
* Optimise backfill calculation (#12522)Richard van der Hoff2022-04-261-16/+14
| | | | | | Try to avoid an OOM by checking fewer extremities. Generally this is a big rewrite of _maybe_backfill, to try and fix some of the TODOs and other problems in it. It's best reviewed commit-by-commit.
* Handle cancellation in `EventsWorkerStore._get_events_from_cache_or_db` (#12529)Sean Quah2022-04-251-34/+49
| | | | | | | | Multiple calls to `EventsWorkerStore._get_events_from_cache_or_db` can reuse the same database fetch, which is initiated by the first call. Ensure that cancelling the first call doesn't cancel the other calls sharing the same database fetch. Signed-off-by: Sean Quah <seanq@element.io>
* Update `delay_cancellation` to accept any awaitable (#12468)Sean Quah2022-04-221-2/+1
| | | | | | | | This will mainly be useful when dealing with module callbacks, which are all typed as returning `Awaitable`s instead of coroutines or `Deferred`s. Signed-off-by: Sean Quah <seanq@element.io>
* Await un-partial-stating after a partial-state join (#12399)Richard van der Hoff2022-04-214-4/+155
| | | | | | When we join a room via the faster-joins mechanism, we end up with "partial state" at some points on the event DAG. Many parts of the codebase need to wait for the full state to load. So, we implement a mechanism to keep track of which events have partial state, and wait for them to be fully-populated.
* Implement MSC2815: allow room moderators to view redacted event content (#12427)Tulir Asokan2022-04-201-0/+18
| | | | | | Implements matrix-org/matrix-spec-proposals#2815 Signed-off-by: Tulir Asokan <tulir@maunium.net>
* Fix returned count of delete extremities admin API (#12496)Erik Johnston2022-04-191-3/+5
|
* Fix grammatical error in error message (#12483)Travis Ralston2022-04-181-1/+1
| | | | | * Fix grammatical error in error message * changelog
* Only send out device list updates for our own users (#12465)Erik Johnston2022-04-141-1/+3
| | | Broke in #12365
* Fix missing sync events during historical batch imports (#12319)Nick Mills-Barrett2022-04-131-0/+26
| | | | | | | | Discovered after much in-depth investigation in #12281. Closes: #12281 Closes: #3305 Signed off by: Nick Mills-Barrett nick@beeper.com
* Process device list updates asynchronously (#12365)Erik Johnston2022-04-122-55/+12
|
* Resync state after partial-state join (#12394)Richard van der Hoff2022-04-125-0/+174
| | | | | We work through all the events with partial state, updating the state at each of them. Once it's done, we recalculate the state for the whole room, and then mark the room as having complete state.
* Remove references to unstable identifiers from MSC3440. (#12382)Patrick Cloke2022-04-122-66/+17
| | | | | Removes references to unstable thread relation, unstable identifiers for filtering parameters, and the experimental config flag.
* Add some type hints to datastore (#12423)Dirk Klimpel2022-04-127-75/+120
| | | | | | | | | | | | | | | | | | | * Add some type hints to datastore * newsfile * change `Collection` to `List` * refactor return type of `select_users_txn` * correct type hint in `stream.py` * Remove `Optional` in `select_users_txn` * remove not needed return type in `__init__` * Revert change in `get_stream_id_for_event_txn` * Remove import from `Literal`
* Do not consider events by ignored users for bundled aggregations (#12235)Patrick Cloke2022-04-111-9/+143
| | | | | | | Consider the requester's ignored users when calculating the bundled aggregations. See #12285 / 4df10d32148ae29f792afc68ff774bcbd1915cea for corresponding changes for the `/relations` endpoint.
* Disallow untyped defs in synapse._scripts (#12422)David Robertson2022-04-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Of note: * No untyped defs in `register_new_matrix_user` This one might be contraversial. `request_registration` has three dependency-injection arguments used for testing. I'm removing the injection of the `requests` module and using `unitest.mock.patch` in the test cases instead. Doing `reveal_type(requests)` and `reveal_type(requests.get)` before the change: ``` synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "Any" synapse/_scripts/register_new_matrix_user.py:46: note: Revealed type is "Any" ``` And after: ``` synapse/_scripts/register_new_matrix_user.py:44: note: Revealed type is "types.ModuleType" synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "def (url: Union[builtins.str, builtins.bytes], params: Union[Union[_typeshed.SupportsItems[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], typing.Iterable[Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]]], builtins.str, builtins.bytes], None] =, data: Union[Any, None] =, headers: Union[Any, None] =, cookies: Union[Any, None] =, files: Union[Any, None] =, auth: Union[Any, None] =, timeout: Union[Any, None] =, allow_redirects: builtins.bool =, proxies: Union[Any, None] =, hooks: Union[Any, None] =, stream: Union[Any, None] =, verify: Union[Any, None] =, cert: Union[Any, None] =, json: Union[Any, None] =) -> requests.models.Response" ``` * Drive-by comment in `synapse.storage.types` * No untyped defs in `synapse_port_db` This was by far the most painful. I'm happy to break this up into smaller pieces for review if it's not managable as-is.
* Optimise `_update_client_ips_batch_txn` to batch together database ↵reivilibre2022-04-082-35/+132
| | | | | operations. (#12252) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix `synapse_event_persisted_position` metric (#12390)Richard van der Hoff2022-04-061-3/+3
| | | | Fixes a bug introduced in #11417 where we would only included backfilled events in `synapse_event_persisted_position`
* Update type annotations for compatiblity with prometheus_client 0.14 (#12389)Richard van der Hoff2022-04-061-3/+1
| | | | | | | Principally, `prometheus_client.REGISTRY.register` now requires its argument to extend `prometheus_client.Collector`. Additionally, `Gauge.set` is now annotated so that passing `Optional[int]` causes an error.
* Generate historic pagination token for `/messages` when no `?from` token ↵Eric Eastwood2022-04-061-9/+11
| | | | provided (#12370)
* Refactor and convert `Linearizer` to async (#12357)Sean Quah2022-04-051-1/+1
| | | | | | | | | | | Refactor and convert `Linearizer` to async. This makes a `Linearizer` cancellation bug easier to fix. Also refactor to use an async context manager, which eliminates an unlikely footgun where code that doesn't immediately use the context manager could forget to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
* Prefill more stream change caches. (#12372)Erik Johnston2022-04-054-38/+89
|
* Prefill the device_list_stream_cache (#12367)Erik Johnston2022-04-041-1/+11
| | | | | | | * Prefill the device_list_stream_cache * Newsfile * Newsfile
* Track device list updates per room. (#12321)Erik Johnston2022-04-044-25/+232
| | | | | | | | | | | | | | This is a first step in dealing with #7721. The idea is basically that rather than calculating the full set of users a device list update needs to be sent to up front, we instead simply record the rooms the user was in at the time of the change. This will allow a few things: 1. we can defer calculating the set of remote servers that need to be poked about the change; and 2. during `/sync` and `/keys/changes` we can avoid also avoid calculating users who share rooms with other users, and instead just look at the rooms that have changed. However, care needs to be taken to correctly handle server downgrades. As such this PR writes to both `device_lists_changes_in_room` and the `device_lists_outbound_pokes` table synchronously. In a future release we can then bump the database schema compat version to `69` and then we can assume that the new `device_lists_changes_in_room` exists and is handled. There is a temporary option to disable writing to `device_lists_outbound_pokes` synchronously, allowing us to test the new code path does work (and by implication upgrading to a future release and downgrading to this one will work correctly). Note: Ideally we'd do the calculation of room to servers on a worker (e.g. the background worker), but currently only master can write to the `device_list_outbound_pokes` table.
* Use a sequence to generate AS transaction IDs, drop `last_txn` AS state (#12209)Nick Mills-Barrett2022-04-013-44/+67
| | | | | | | | Switching to a sequence means there's no need to track `last_txn` on the AS state table to generate new TXN IDs. This also means that there is no longer contention between the AS scheduler and AS handler on updates to the `application_services_state` table, which will prevent serialization errors during the complete AS txn transaction.
* Move `update_client_ip` background job from the main process to the ↵reivilibre2022-04-014-76/+117
| | | | background worker. (#12251)
* Raise an exception when getting state at an outlier (#12191)Richard van der Hoff2022-04-012-4/+32
| | | | | | It seems like calling `_get_state_group_for_events` for an event where the state is unknown is an error. Accordingly, let's raise an exception rather than silently returning an empty result.
* Optimise `_get_state_after_missing_prev_event`: use `/state` (#12040)Richard van der Hoff2022-04-011-5/+3
| | | If we're missing most of the events in the room state, then we may as well call the /state endpoint, instead of individually requesting each and every event.
* Add more type hints to the main state store. (#12267)Patrick Cloke2022-03-311-7/+11
|
* Remove an unnecessary class from the relations code. (#12338)Patrick Cloke2022-03-312-62/+8
| | | | | The PaginationChunk class attempted to bundle some properties together, but really just caused callers to jump through hoops and hid implementation details.
* Remove the unused and unstable `/aggregations` endpoint. (#12293)Patrick Cloke2022-03-302-97/+14
| | | | | | | | | This endpoint was removed from MSC2675 before it was approved. It is currently unspecified (even in any MSCs) and therefore subject to removal. It is not implemented by any known clients. This also changes the bundled aggregation format for `m.annotation`, which previously included pagination tokens for the `/aggregations` endpoint, which are no longer useful.
* Send device list updates to application services (MSC3202) - part 1 (#11881)Andrew Morgan2022-03-303-18/+67
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Start application service stream token tracking from 1 (#12193)Andrew Morgan2022-03-301-1/+2
| | | Co-authored-by: Erik Johnston <erik@matrix.org>
* Add a configuration to exclude rooms from sync response (#12310)Brendan Abolivier2022-03-302-15/+36
|
* Update `LoggingTransaction.call_after` and `call_on_exception` docstrings ↵Sean Quah2022-03-291-3/+20
| | | | | | | | (#12315) Document the behaviour of `LoggingTransaction.call_after` and `LoggingTransaction.call_on_exception` when transactions are retried. Signed-off-by: Sean Quah <seanq@element.io>
* Bump `black` and `click` versions (#12320)David Robertson2022-03-291-1/+1
|
* Exclude outliers in `on_backfill_request` (#12314)Richard van der Hoff2022-03-281-3/+9
| | | | | | When we are processing a `/backfill` request from a remote server, exclude any outliers from consideration early on. We can't return outliers anyway (since we don't know the state at the outlier), and filtering them out earlier means that we won't attempt to calulate the state for them.
* Add some type hints to datastore. (#12255)Dirk Klimpel2022-03-288-39/+60
|
* Improve type annotations for `execute_values`. (#12311)reivilibre2022-03-281-10/+7
|
* Add cache for `get_membership_from_event_ids` (#12272)Erik Johnston2022-03-254-8/+55
| | | | | This should speed up push rule calculations for rooms with large numbers of local users when the main push rule cache fails. Co-authored-by: reivilibre <oliverw@matrix.org>
* Refuse to start if DB has an unsafe locale (#12262)Shay2022-03-231-15/+30
|
* Use psycopg2 type stubs (#12269)David Robertson2022-03-232-4/+12
|
* Rename shared_rooms to mutual_rooms (#12036)Jonathan de Jong2022-03-231-3/+3
| | | Co-authored-by: reivilibre <olivier@librepush.net>
* Move get_bundled_aggregations to relations handler. (#12237)Patrick Cloke2022-03-181-146/+5
| | | | | The get_bundled_aggregations code is fairly high-level and uses a lot of store methods, we move it into the handler as that seems like a better fit.
* Only fetch thread participation for events with threads. (#12228)Patrick Cloke2022-03-181-1/+3
| | | | | | | | | We fetch the thread summary in two phases: 1. The summary that is shared by all users (count of messages and latest event). 2. Whether the requesting user has participated in the thread. There's no use in attempting step 2 for events which did not return a summary from step 1.
* Add some type hints to datastore (#12248)Dirk Klimpel2022-03-182-78/+116
| | | | | * inherit `MonthlyActiveUsersStore` from `RegistrationWorkerStore` Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Correct `check_username_for_spam` annotations and docs (#12246)David Robertson2022-03-181-4/+19
| | | | | | | * Formally type the UserProfile in user searches * export UserProfile in synapse.module_api * Update docs Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Handle cancellation in `DatabasePool.runInteraction()` (#12199)Sean Quah2022-03-161-24/+37
| | | | | | | | | | | | To handle cancellation, we ensure that `after_callback`s and `exception_callback`s are always run, since the transaction will complete on another thread regardless of cancellation. We also wait until everything is done before releasing the `CancelledError`, so that logging contexts won't get used after they have been finished. Signed-off-by: Sean Quah <seanq@element.io>
* Add some missing type hints to cache datastore. (#12216)Patrick Cloke2022-03-161-21/+36
|
* Use the ignored_users table to test event visibility & sync. (#12225)Patrick Cloke2022-03-151-3/+38
| | | | | Instead of fetching the raw account data and re-parsing it. The ignored_users table is a denormalised version of the account data for quick searching.
* Fix broken background updates when using sqlite with `enable_search` off ↵Sean Quah2022-03-141-6/+7
| | | | | (#12215) Signed-off-by: Sean Quah <seanq@element.io>
* Add config settings for background update parameters (#11980)Shay2022-03-111-14/+25
|
* Remove unnecessary pass statements. (#12206)Patrick Cloke2022-03-112-3/+0
|
* Support stable identifiers for MSC3440: Threading (#12151)Patrick Cloke2022-03-103-39/+61
| | | | The unstable identifiers are still supported if the experimental configuration flag is enabled. The unstable identifiers will be removed in a future release.
* Allow retrieving the relations of a redacted event. (#12130)Patrick Cloke2022-03-103-33/+42
| | | | | | | | | This is allowed per MSC2675, although the original implementation did not allow for it and would return an empty chunk / not bundle aggregations. The main thing to improve is that the various caches get cleared properly when an event is redacted, and that edits must not leak if the original event is redacted (as that would presumably leak something similar to the original event content).
* Allow for ignoring some arguments when caching. (#12189)Patrick Cloke2022-03-091-2/+2
| | | | | * `@cached` can now take an `uncached_args` which is an iterable of names to not use in the cache key. * Requires `@cached`, @cachedList` and `@lru_cache` to use keyword arguments for clarity. * Asserts that keyword-only arguments in cached functions are not accepted. (I tested this briefly and I don't believe this works properly.)
* Remove some unused variables/parameters. (#12187)Patrick Cloke2022-03-091-9/+5
|
* Fix a bug in background updates wherein background updates are never run ↵Shay2022-03-071-3/+5
| | | | using the default batch size (#12157)
* Invalidate caches when an event with a relation is redacted. (#12121)Patrick Cloke2022-03-072-5/+35
| | | | | The caches for the target of the relation must be cleared so that the bundled aggregations are re-calculated after the redaction is processed.
* Reduce to-device queries for /sync. (#12163)Erik Johnston2022-03-041-0/+3
|
* Remove backwards compatibility with RelationPaginationToken. (#12138)Patrick Cloke2022-03-041-31/+0
|
* Fix type of `events` in `StateGroupStorage` and `StateHandler` (#12156)Richard van der Hoff2022-03-041-4/+4
| | | We make multiple passes over this, so a regular iterable won't do.
* Back out in-flight state caching changes. (#12126)reivilibre2022-03-021-218/+25
|
* Make get_room_version use cached get_room_version_id. (#11808)lukasdenk2022-03-021-14/+13
|
* Order in-flight state group queries in biggest-first order (#11610)reivilibre2022-03-011-3/+27
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Faster joins: persist to database (#12012)Richard van der Hoff2022-03-015-0/+203
| | | | | | | | | | | | When we get a partial_state response from send_join, store information in the database about it: * store a record about the room as a whole having partial state, and stash the list of member servers too. * flag the join event itself as having partial state * also, for any new events whose prev-events are partial-stated, note that they will *also* be partial-stated. We don't yet make any attempt to interpret this data, so API calls (and a bunch of other things) are just going to get incorrect data.
* Ensure that `get_datastores().main` is typed (#12070)Sean Quah2022-02-251-1/+2
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Minor typing fixes for `synapse/storage/persist_events.py` (#12069)Sean Quah2022-02-252-23/+25
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Add support for MSC3202: sending one-time key counts and fallback key usage ↵reivilibre2022-02-242-2/+143
| | | | | states to Application Services. (#11617) Co-authored-by: Erik Johnston <erik@matrix.org>
* Fix non-strings in the `event_search` table (#12037)Sean Quah2022-02-243-9/+57
| | | | | | | Don't attempt to add non-string `value`s to `event_search` and add a background update to clear out bad rows from `event_search` when using sqlite. Signed-off-by: Sean Quah <seanq@element.io>
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-1/+1
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Cap the number of in-flight requests for state from a single group (#11608)reivilibre2022-02-221-0/+16
|
* Fix slow performance of `/logout` in some cases where refresh tokens are in ↵reivilibre2022-02-222-2/+44
| | | | use. The slowness existed since the initial implementation of refresh tokens. (#12056)
* remote join processing: get create event from state, not auth_chain (#12039)Richard van der Hoff2022-02-211-2/+2
| | | A follow-up to #12005, in which I apparently missed that there are a bunch of other places that assume the create event is in the auth chain.
* Add type hints to `synapse/storage/databases/main` (#11984)Dirk Klimpel2022-02-213-35/+61
|
* Document why auth providers aren't validated in the admin API. (#12004)Patrick Cloke2022-02-181-0/+21
| | | | Since it is reasonable to give a future or past auth provider, which might not be in the current configuration.
* Track and deduplicate in-flight requests to `_get_state_for_groups`. (#10870)reivilibre2022-02-181-25/+178
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix bug in `StateFilter.return_expanded()` and add some tests. (#12016)reivilibre2022-02-181-1/+7
|
* Fix 500 error with Postgres when looking backwards with the MSC3030 ↵Eric Eastwood2022-02-181-1/+1
| | | | `/timestamp_to_event` endpoint (#12024)
* Fix a typo in a comment.Patrick Cloke2022-02-161-1/+1
|
* Optimise calculating device_list changes in `/sync`. (#11974)Erik Johnston2022-02-152-0/+72
| | | | | | For users with large accounts it is inefficient to calculate the set of users they share a room with (and takes a lot of space in the cache). Instead we can look at users whose devices have changed since the last sync and check if they share a room with the syncing user.
* Fix incorrect `get_rooms_for_user` for remote user (#11999)Erik Johnston2022-02-151-11/+16
| | | | | | | When the server leaves a room the `get_rooms_for_user` cache is not correctly invalidated for the remote users in the room. This means that subsequent calls to `get_rooms_for_user` for the remote users would incorrectly include the room (it shouldn't be included because the server no longer knows anything about the room).
* Refactor search code to reduce function size. (#11991)Patrick Cloke2022-02-151-7/+10
| | | | | | | | | Splits the search code into a few logical functions instead of a single unreadable function. There are also a few additional changes for readability. After refactoring it was clear to see there were some unused and unnecessary variables, which were simplified.
* Fix incorrect thread summaries when the latest event is edited. (#11992)Patrick Cloke2022-02-152-7/+19
| | | | | If the latest event in a thread was edited than the original event content was included in bundled aggregation for threads instead of the edited event content.
* Implement MSC3706: partial state in `/send_join` response (#11967)Richard van der Hoff2022-02-121-6/+6
| | | | | | | | | | | | * Make `get_auth_chain_ids` return a Set It has a set internally, and a set is often useful where it gets used, so let's avoid converting to an intermediate list. * Minor refactors in `on_send_join_request` A little bit of non-functional groundwork * Implement MSC3706: partial state in /send_join response
* Fetch thread summaries for multiple events in a single query (#11752)Patrick Cloke2022-02-112-74/+150
| | | | | This should reduce database usage when fetching bundled aggregations as the number of individual queries (and round trips to the database) are reduced.
* Fix to-device being dropped in limited sync in SQLite. (#11966)Erik Johnston2022-02-111-1/+4
| | | | | | | | | If ther are more than 100 to-device messages pending for a device `/sync` will only return the first 100, however the next batch token was incorrectly calculated and so all other pending messages would be dropped. This is due to `txn.rowcount` only returning the number of rows that *changed*, rather than the number *selected* in SQLite.
* Support pagination tokens from /sync and /messages in the relations API. ↵Patrick Cloke2022-02-102-21/+40
| | | | (#11952)
* Experimental support to include bundled aggregations in search results ↵Patrick Cloke2022-02-081-2/+11
| | | | (MSC3666) (#11837)
* Fetch edits for multiple events in a single query. (#11660)Patrick Cloke2022-02-082-54/+100
| | | | | This should reduce database usage when fetching bundled aggregations as the number of individual queries (and round trips to the database) are reduced.
* Add a docstring to `add_device_change_to_streams` and fix some nearby types ↵Andrew Morgan2022-02-081-6/+16
| | | | (#11912)
* Fix historical messages backfilling in random order on remote homeservers ↵Eric Eastwood2022-02-072-103/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (MSC2716) (#11114) Fix https://github.com/matrix-org/synapse/issues/11091 Fix https://github.com/matrix-org/synapse/issues/10764 (side-stepping the issue because we no longer have to deal with `fake_prev_event_id`) 1. Made the `/backfill` response return messages in `(depth, stream_ordering)` order (previously only sorted by `depth`) - Technically, it shouldn't really matter how `/backfill` returns things but I'm just trying to make the `stream_ordering` a little more consistent from the origin to the remote homeservers in order to get the order of messages from `/messages` consistent ([sorted by `(topological_ordering, stream_ordering)`](https://github.com/matrix-org/synapse/blob/develop/docs/development/room-dag-concepts.md#depth-and-stream-ordering)). - Even now that we return backfilled messages in order, it still doesn't guarantee the same `stream_ordering` (and more importantly the [`/messages` order](https://github.com/matrix-org/synapse/blob/develop/docs/development/room-dag-concepts.md#depth-and-stream-ordering)) on the other server. For example, if a room has a bunch of history imported and someone visits a permalink to a historical message back in time, their homeserver will skip over the historical messages in between and insert the permalink as the next message in the `stream_order` and totally throw off the sort. - This will be even more the case when we add the [MSC3030 jump to date API endpoint](https://github.com/matrix-org/matrix-doc/pull/3030) so the static archives can navigate and jump to a certain date. - We're solving this in the future by switching to [online topological ordering](https://github.com/matrix-org/gomatrixserverlib/issues/187) and [chunking](https://github.com/matrix-org/synapse/issues/3785) which by its nature will apply retroactively to fix any inconsistencies introduced by people permalinking 2. As we're navigating `prev_events` to return in `/backfill`, we order by `depth` first (newest -> oldest) and now also tie-break based on the `stream_ordering` (newest -> oldest). This is technically important because MSC2716 inserts a bunch of historical messages at the same `depth` so it's best to be prescriptive about which ones we should process first. In reality, I think the code already looped over the historical messages as expected because the database is already in order. 3. Making the historical state chain and historical event chain float on their own by having no `prev_events` instead of a fake `prev_event` which caused backfill to get clogged with an unresolvable event. Fixes https://github.com/matrix-org/synapse/issues/11091 and https://github.com/matrix-org/synapse/issues/10764 4. We no longer find connected insertion events by finding a potential `prev_event` connection to the current event we're iterating over. We now solely rely on marker events which when processed, add the insertion event as an extremity and the federating homeserver can ask about it when time calls. - Related discussion, https://github.com/matrix-org/synapse/pull/11114#discussion_r741514793 Before | After --- | --- ![](https://user-images.githubusercontent.com/558581/139218681-b465c862-5c49-4702-a59e-466733b0cf45.png) | ![](https://user-images.githubusercontent.com/558581/146453159-a1609e0a-8324-439d-ae44-e4bce43ac6d1.png) #### Why aren't we sorting topologically when receiving backfill events? > The main reason we're going to opt to not sort topologically when receiving backfill events is because it's probably best to do whatever is easiest to make it just work. People will probably have opinions once they look at [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) which could change whatever implementation anyway. > > As mentioned, ideally we would do this but code necessary to make the fake edges but it gets confusing and gives an impression of “just whyyyy” (feels icky). This problem also dissolves with online topological ordering. > > -- https://github.com/matrix-org/synapse/pull/11114#discussion_r741517138 See https://github.com/matrix-org/synapse/pull/11114#discussion_r739610091 for the technical difficulties
* Invalidate the get_users_in_room{_with_profile} caches only when necessary. ↵Patrick Cloke2022-02-022-8/+19
| | | | | | | (#11878) The get_users_in_room and get_users_in_room_with_profiles are now only invalidated when the membership of a room changes, instead of during any state change in the room.
* Revert experimental push rules from #7997. (#11884)Patrick Cloke2022-02-021-16/+4
| | | Manually reverts the merge from cdbb8e6d6e36e0b6bc36e676d8fe66c96986b399.
* Add a background database update to purge account data for deactivated ↵reivilibre2022-02-022-55/+129
| | | | users. (#11655)
* Send to-device messages to application services (#11215)Andrew Morgan2022-02-013-46/+275
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove the obsolete MSC1849 configuration flag. (#11843)Patrick Cloke2022-01-311-4/+0
| | | | | MSC1849 was replaced by MSC2675, which was merged. The configuration flag, which defaulted to true, is no longer useful.
* Pass `isolation_level` to `runWithConnection` (#11847)Brendan Abolivier2022-01-271-0/+1
| | | This was missed in https://github.com/matrix-org/synapse/pull/11799
* Create singletons for `StateFilter.{all,none}()` (#11836)Richard van der Hoff2022-01-271-5/+9
| | | No point recreating these for each call, since they are frozen
* Include `prev_content` field in AS events (#11798)Vaishnav Nair2022-01-261-1/+1
| | | | | | * Include 'prev_content' field in AS events Signed-off-by: Vaishnav Nair <nairvaishnav007@icloud.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Improvements to bundling aggregations. (#11815)Patrick Cloke2022-01-262-30/+53
| | | | | | | | | | | This is some odds and ends found during the review of #11791 and while continuing to work in this code: * Return attrs classes instead of dictionaries from some methods to improve type safety. * Call `get_bundled_aggregations` fewer times. * Adds a missing assertion in the tests. * Do not return empty bundled aggregations for an event (preferring to not include the bundle at all, as the docstring states).
* Add admin API to get a list of federated rooms (#11658)Dirk Klimpel2022-01-251-0/+48
|
* Db txn set isolation level (#11799)Nick Barrett2022-01-254-5/+60
| | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Minor updates, and docs, for schema delta files (#11823)Richard van der Hoff2022-01-251-3/+6
| | | | | | | | | * Make functions in python deltas optional It's annoying to always have to write stubs for these. * Documentation for delta files * changelog
* Merge tag 'v1.51.0rc2' into developAndrew Morgan2022-01-241-1/+4
|\ | | | | | | | | | | | | | | | | | | Synapse 1.51.0rc2 (2022-01-24) ============================== Bugfixes -------- - Fix a bug introduced in Synapse 1.40.0 that caused Synapse to fail to process incoming federation traffic after handling a large amount of events in a v1 room. ([\#11806](https://github.com/matrix-org/synapse/issues/11806))
| * Fix logic for dropping old events in fed queue (#11806)Andrew Morgan2022-01-241-1/+4
| | | | | | | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Richard van der Hoff <richard@matrix.org>
* | Remove account data (including client config, push rules and ignored users) ↵reivilibre2022-01-241-2/+71
| | | | | | | | | | upon user deactivation. (#11621) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Drop support for and remove references to EOL Python 3.6 (#11683)Shay2022-01-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * remove reference in comments to python3.6 * upgrade tox python env in script * bump python version in example for completeness * upgrade python version requirement in setup doc * upgrade necessary python version in __init__.py * upgrade python version in setup.py * newsfragment * drops refs to bionic and replace with focal * bump refs to postgres 9.6 to 10 * fix hanging ci * try installing tzdata first * revert change made in b979f336 * ignore new random mypy error while debugging other error * fix lint error for temporary workaround * revert change to install list * try passing env var * export debian frontend var? * move line and add comment * bump pillow dependency * bump lxml depenency * install libjpeg-dev for pillow * bump automat version to one compatible with py3.8 * add libwebp for pillow * bump twisted trunk python version * change suffix of newsfragment * remove redundant python 3.7 checks * lint
* | Add `state_key` and `rejection_reason` to `events` (#11792)Richard van der Hoff2022-01-213-4/+37
| | | | | | | | ... and start populating them for new events
* | Drop unused table `public_room_list_stream`. (#11795)Richard van der Hoff2022-01-213-2/+21
| | | | | | This is a follow-up to #10565.
* | Stop reading from `event_reference_hashes` (#11794)Richard van der Hoff2022-01-213-32/+29
| | | | | | | | Preparation for dropping this table altogether. Part of #6574.
* | Make the `get_global_account_data_by_type_for_user` cache be a tree-cache ↵reivilibre2022-01-211-4/+4
| | | | | | | | whose key is prefixed with the user ID (#11788)
* | Make `get_account_data_for_room_and_type` a tree cache (#11789)reivilibre2022-01-211-1/+1
|/
* Debug for device lists updates (#11760)David Robertson2022-01-201-0/+18
| | | | | | | | | | | | | | | | | | Debug for #8631. I'm having a hard time tracking down what's going wrong in that issue. In the reported example, I could see server A sending federation traffic to server B and all was well. Yet B reports out-of-sync device updates from A. I couldn't see what was _in_ the events being sent from A to B. So I have added some crude logging to track - when we have updates to send to a remote HS - the edus we actually accumulate to send - when a federation transaction includes a device list update edu - when such an EDU is received This is a bit of a sledgehammer.
* Comments and typing for `_update_outliers_txn` (#11776)Richard van der Hoff2022-01-191-12/+23
| | | | A couple of surprises for me here, so thought I'd document them
* Include whether the requesting user has participated in a thread. (#11577)Patrick Cloke2022-01-182-11/+62
| | | | | | Per updates to MSC3440. This is implement as a separate method since it needs to be cached on a per-user basis, instead of a per-thread basis.
* Remove `log_function` and its uses (#11761)Richard van der Hoff2022-01-181-2/+0
| | | | | | | I've never found this terribly useful. I think it was added in the early days of Synapse, without much thought as to what would actually be useful to log, and has just been cargo-culted ever since. Rather, it tends to clutter up debug logs with useless information.
* Make pagination of rooms in admin api stable (#11737)Daniel Sonck2022-01-171-9/+9
| | | | | | | | | | | | | | Always add state.room_id after the configurable ORDER BY. Otherwise, for any sort, certain pages can contain results from other pages. (Especially when sorting by creator, since there may be many rooms by the same creator) * Document different order direction of numerical fields "joined_members", "joined_local_members", "version" and "state_events" are ordered in descending direction by default (dir=f). Added a note in tests to explain the differences in ordering. Signed-off-by: Daniël Sonck <daniel@sonck.nl>
* Merge branch 'release-v1.50' into developOlivier Wilkinson (reivilibre)2022-01-141-17/+85
|\
| * Fix a bug introduced in Synapse v1.50.0rc1 whereby outbound federation could ↵reivilibre2022-01-131-16/+78
| | | | | | | | | | fail because too many EDUs were produced for device updates. (#11730) Co-authored-by: David Robertson <davidr@element.io>
| * Fix a bug introduced in Synapse v1.0.0 whereby device list updates would not ↵reivilibre2022-01-121-1/+7
| | | | | | | | | | be sent to remote homeservers if there were too many to send at once. (#11729) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* | Replace uses of simple_insert_many with simple_insert_many_values. (#11742)Patrick Cloke2022-01-1315-251/+224
| | | | | | | | This should be (slightly) more efficient and it is simpler to have a single method for inserting multiple values.
* | Use auto_attribs/native type hints for attrs classes. (#11692)Patrick Cloke2022-01-1312-61/+61
| |
* | Fix docstring on `add_account_data_for_user`. (#11716)reivilibre2022-01-101-1/+1
| |
* | Bundle aggregations outside of the serialization method. (#11612)Patrick Cloke2022-01-071-3/+125
| | | | | | | | | | | | | | | | This makes the serialization of events synchronous (and it no longer access the database), but we must manually calculate and provide the bundled aggregations. Overall this should cause no change in behavior, but is prep work for other improvements.
* | Fix get federation status of destination if no error occured (#11593)Dirk Klimpel2022-01-051-0/+11
| |
* | Run `pyupgrade --py37-plus --keep-percent-format` on Synapse (#11685)Shay2022-01-051-1/+0
| | | | | | | | | | | | | | | | | | * newsfragment * fix newsfragment number * update changelog * remove extra space
* | Cache empty responses from `/user/devices` (#11587)David Robertson2022-01-051-2/+6
|/ | | If we've never made a request to a remote homeserver, we should cache the response---even if the response is "this user has no devices".
* Remove redundant `get_current_events_token` (#11643)Richard van der Hoff2022-01-043-25/+17
| | | | | | | | | | | | | | | | | * Push `get_room_{min,max_stream_ordering}` into StreamStore Both implementations of this are identical, so we may as well push it down and get rid of the abstract base class nonsense. * Remove redundant `StreamStore` class This is empty now * Remove redundant `get_current_events_token` This was an exact duplicate of `get_room_max_stream_ordering`, so let's get rid of it. * newsfile
* Better error messages from `get_create_event_for_room` (#11638)Richard van der Hoff2022-01-041-1/+5
| | | | "Unknown room" can mean a multitude of things here. To help with debugging, add some more words to the exception text.
* Convert all namedtuples to attrs. (#11665)Patrick Cloke2021-12-306-37/+54
| | | To improve type hints throughout the code.
* Add type hints to `synapse/storage/databases/main/events_bg_updates.py` (#11654)Dirk Klimpel2021-12-301-29/+40
|
* Improve type hints in storage classes. (#11652)Dirk Klimpel2021-12-299-34/+43
| | | By using cast and making ignores more specific.
* Add type hints to `synapse/storage/databases/main/stats.py` (#11653)Dirk Klimpel2021-12-291-41/+53
|
* Add type hints to event_push_actions. (#11594)Patrick Cloke2021-12-211-91/+158
|
* Add type hints to `synapse/storage/databases/main/transactions.py` (#11589)Dirk Klimpel2021-12-161-24/+25
|
* Add type hints to `synapse/storage/databases/main/room.py` (#11575)Sean Quah2021-12-152-74/+100
|
* Require Collections as the parameters for simple_* methods. (#11580)Patrick Cloke2021-12-152-40/+11
| | | | Instead of Iterable since the generators are not allowed due to the potential for their re-use.
* Add experimental support for MSC3202: allowing application services to ↵reivilibre2021-12-151-0/+20
| | | | masquerade as specific devices. (#11538)
* Add type hints to `synapse/storage/databases/main/e2e_room_keys.py` (#11549)Sean Quah2021-12-141-70/+167
|
* Remove redundant `COALESCE()`s around `COUNT()`s in database queries (#11570)Sean Quah2021-12-147-20/+18
| | | | | `COUNT()` never returns `NULL`. A `COUNT(*)` over 0 rows is 0 and a `COUNT(NULL)` is also 0.
* checks for generators in database functions (#11564)Richard van der Hoff2021-12-132-7/+48
| | | | | A couple of safety-checks to hopefully stop people doing what I just did, and create a storage function which only works the first time it is called (and not when it is re-run due to a database concurrency error or similar).
* Type hint the constructors of the data store classes (#11555)Sean Quah2021-12-1328-75/+308
|
* Add type hints to `synapse/storage/databases/main/end_to_end_keys.py` (#11551)Sean Quah2021-12-132-68/+146
|
* Add type hints to `synapse/storage/databases/main/account_data.py` (#11546)Sean Quah2021-12-132-32/+83
|
* Make `get_device` return None if the device doesn't exist rather than ↵reivilibre2021-12-131-4/+6
| | | | | raising an exception. (#11565) Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* skip some dict munging in event persistence (#11560)Richard van der Hoff2021-12-102-60/+113
| | | | | | Create a new dict helper method `simple_insert_many_values_txn`, which takes raw row values, rather than {key=>value} dicts. This saves us a bunch of dict munging, and makes it easier to use generators rather than creating intermediate lists and dicts.
* Stop populating `state_events.prev_state` (#11558)Richard van der Hoff2021-12-102-5/+4
| | | this field is never read, so we may as well stop populating it.
* Ensure emails are canonicalized before fetching associated user. (#11547)Patrick Cloke2021-12-102-2/+4
| | | | This should fix pushers with an email in non-canonical form is used as the pushkey.
* Do not allow cross-room relations, per MSC2674. (#11516)Patrick Cloke2021-12-092-12/+32
|
* Add a constant for receipt types (m.read). (#11531)Patrick Cloke2021-12-081-33/+68
| | | And expand some type hints in the receipts storage module.
* Improve log messages for stream ids (#11536)Richard van der Hoff2021-12-082-4/+6
| | | | Somehow I'd managed to get my database in a pickle with stream ids. These changes were useful to debug.
* Send and handle cross-signing messages using the stable prefix. (#10520)Hubert Chathi2021-12-081-1/+3
|
* Save the OIDC session ID (sid) with the device on login (#11482)Quentin Gliech2021-12-062-1/+76
| | | As a step towards allowing back-channel logout for OIDC.
* Add admin API to get some information about federation status (#11407)Dirk Klimpel2021-12-061-0/+70
|
* Disambiguate queries on `state_key` (#11497)Richard van der Hoff2021-12-026-16/+20
| | | | | We're going to add a `state_key` column to the `events` table, so we need to add some disambiguation to queries which use it.
* Comments on the /sync tentacles (#11494)David Robertson2021-12-021-4/+11
| | | | | This mainly consists of docstrings and inline comments. There are one or two type annotations and variable renames thrown in while I was here. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add type annotations to `tests.storage.test_appservice`. (#11488)reivilibre2021-12-021-3/+3
|
* Add MSC3030 experimental client and federation API endpoints to get the ↵Eric Eastwood2021-12-021-0/+195
| | | | | | | | | | | | | | | | | | | | | | | | | closest event to a given timestamp (#9445) MSC3030: https://github.com/matrix-org/matrix-doc/pull/3030 Client API endpoint. This will also go and fetch from the federation API endpoint if unable to find an event locally or we found an extremity with possibly a closer event we don't know about. ``` GET /_matrix/client/unstable/org.matrix.msc3030/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction> { "event_id": ... "origin_server_ts": ... } ``` Federation API endpoint: ``` GET /_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction> { "event_id": ... "origin_server_ts": ... } ``` Co-authored-by: Erik Johnston <erik@matrix.org>
* Improved push typing (#11409)Marcus2021-11-301-2/+17
| | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Refactor `backfilled` into specific behavior function arguments ↵Eric Eastwood2021-11-292-21/+56
| | | | | | | | | | | | | | | (`_persist_events_and_state_updates`) (#11417) Part of https://github.com/matrix-org/synapse/issues/11300 Call stack: - `_persist_events_and_state_updates` (added `use_negative_stream_ordering`) - `_persist_events_txn` - `_update_room_depths_txn` (added `update_room_forward_stream_ordering`) - `_update_metadata_tables_txn` - `_store_room_members_txn` (added `inhibit_local_membership_updates`) Using keyword-only arguments (`*`) to reduce the mistakes from `backfilled` being left as a positional argument somewhere and being interpreted wrong by our new arguments.
* Make background updates controllable via a plugin (#11306)Erik Johnston2021-11-291-23/+169
| | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add type hints to `synapse/storage/databases/main/events_worker.py` (#11411)Sean Quah2021-11-265-148/+230
| | | | Also refactor the stream ID trackers/generators a bit and try to document them better.
* Support expiry of refresh tokens and expiry of the overall session when ↵reivilibre2021-11-262-2/+54
| | | | refresh tokens are in use. (#11425)
* Track ongoing event fetches correctly (again) (#11376)Sean Quah2021-11-261-42/+112
| | | | | | | | | | | | | The previous fix for the ongoing event fetches counter (8eec25a1d9d656905db18a2c62a5552e63db2667) was both insufficient and incorrect. When the database is unreachable, `_do_fetch` never gets run and so `_event_fetch_ongoing` is never decremented. The previous fix also moved the `_event_fetch_ongoing` decrement outside of the `_event_fetch_lock` which allowed race conditions to corrupt the counter.
* Improve performance of `remove_{hidden,deleted}_devices_from_device_inbox` ↵Brendan Abolivier2021-11-252-146/+81
| | | | | (#11421) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Lower minumum batch size to 1 for background updates (#11422)Brendan Abolivier2021-11-241-1/+1
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add missing type hints to config base classes (#11377)Patrick Cloke2021-11-231-1/+2
|
* Remove code invalidated by deprecated config flag ↵Shay2021-11-231-32/+3
| | | | | | | | | | | | | | | | | | | | | 'trust_identity_servers_for_password_resets' (#11395) * remove background update code related to deprecated config flag * changelog entry * update changelog * Delete 11394.removal Duplicate, wrong number * add no-op background update and change newfragment so it will be consolidated with associated work * remove unused code * Remove code associated with deprecated flag from legacy docker dynamic config file Co-authored-by: reivilibre <oliverw@matrix.org>
* Store arbitrary relations from events. (#11391)Patrick Cloke2021-11-223-44/+75
| | | | | Instead of only known relation types. This also reworks the background update for thread relations to crawl events and search for any relation type, not just threaded relations.
* Add an admin API to run background jobs. (#11352)Dirk Klimpel2021-11-191-0/+2
| | | | | | Instead of having admins poke into the database directly. Can currently run jobs to populate stats and to populate the user directory.
* Keep fallback key marked as used if it's re-uploaded (#11382)Hubert Chathi2021-11-191-11/+40
|
* Add dedicated admin API for blocking a room (#11324)Dirk Klimpel2021-11-181-0/+32
|