summary refs log tree commit diff
path: root/synapse/storage/databases/main/state.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Bump black from 23.10.1 to 24.2.0 (#16936)dependabot[bot]2024-03-131-4/+2
|
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-231-0/+2
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* 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>
* Update license headersPatrick Cloke2023-11-211-11/+16
|
* Convert simple_select_many_batch, simple_select_many_txn to tuples. (#16444)Patrick Cloke2023-10-111-24/+38
|
* Return immutable objects for cachedList decorators (#16350)Patrick Cloke2023-09-191-2/+12
|
* Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-221-1/+0
|
* Enable Faster Remote Room Joins against worker-mode Synapse. (#14752)reivilibre2023-01-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable Complement tests for Faster Remote Room Joins on worker-mode * (dangerous) Add an override to allow Complement to use FRRJ under workers * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Fix race where we didn't send out replication notification * MORE HACKS * Fix get_un_partial_stated_rooms_token to take instance_name * Fix bad merge * Remove warning * Correctly advance un_partial_stated_room_stream * Fix merge * Add another notify_replication * Fixups * Create a separate ReplicationNotifier * Fix test * Fix portdb * Create a separate ReplicationNotifier * Fix test * Fix portdb * Fix presence test * Newsfile * Apply suggestions from code review * Update changelog.d/14752.misc Co-authored-by: Erik Johnston <erik@matrix.org> * lint Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Erik Johnston <erik@matrix.org>
* Faster remote room joins: invalidate caches and unblock requests when ↵reivilibre2022-12-191-1/+17
| | | | receiving un-partial-stated event notifications over replication. [rei:frrj/streams/unpsr] (#14546)
* Faster remote room joins: stream the un-partial-stating of events over ↵reivilibre2022-12-141-9/+25
| | | | replication. [rei:frrj/streams/unpsr] (#14545)
* Move `StateFilter` to `synapse.types` (#14668)David Robertson2022-12-121-1/+1
| | | | | * Move `StateFilter` to `synapse.types` * Changelog
* Instrument `get_metadata_for_events` for tracing (#13730)Eric Eastwood2022-09-071-0/+2
| | | | When backfilling, `_get_state_ids_after_missing_prev_event` calls [`get_metadata_for_events`](https://github.com/matrix-org/synapse/blob/26bc26586b4b95d63ce7e453e9312469843f796e/synapse/handlers/federation_event.py#L1133). For `#matrix:matrix.org`, it's called with 77k `state_events` which means 77 calls to the database and takes 28 seconds.
* Cancel the processing of key query requests when they time out. (#13680)reivilibre2022-09-071-0/+2
|
* Update the rejected state of events during resync (#13459)Richard van der Hoff2022-08-111-0/+5
| | | | | Events can be un-rejected or newly-rejected during resync, so ensure we update the database and caches when that happens.
* Faster joins: fix rejected events becoming un-rejected during resync (#13413)Richard van der Hoff2022-08-011-3/+5
| | | | | Make sure that we re-check the auth rules during state resync, otherwise rejected events get un-rejected.
* Faster joins: add issue links to the TODOs (#13004)Richard van der Hoff2022-06-091-0/+1
| | | | ... to help us keep track of these things
* Fix a stale comment in get_room_version_id_txn. (#12969)Patrick Cloke2022-06-071-6/+1
|
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-011-29/+9
|
* Fix 404 on `/sync` when the last event is a redaction of an unknown/purged ↵Richard van der Hoff2022-06-011-3/+9
| | | | | | | | | | | 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.
* 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).
* Pull out less state when handling gaps mk2 (#12852)Erik Johnston2022-05-261-0/+59
|
* 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-271-2/+2
|
* Await un-partial-stating after a partial-state join (#12399)Richard van der Hoff2022-04-211-0/+1
| | | | | | 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.
* Fix grammatical error in error message (#12483)Travis Ralston2022-04-181-1/+1
| | | | | * Fix grammatical error in error message * changelog
* Resync state after partial-state join (#12394)Richard van der Hoff2022-04-121-0/+48
| | | | | 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.
* Add some type hints to datastore (#12423)Dirk Klimpel2022-04-121-1/+1
| | | | | | | | | | | | | | | | | | | * 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`
* Raise an exception when getting state at an outlier (#12191)Richard van der Hoff2022-04-011-4/+12
| | | | | | 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.
* Add more type hints to the main state store. (#12267)Patrick Cloke2022-03-311-7/+11
|
* Add some type hints to datastore. (#12255)Dirk Klimpel2022-03-281-9/+15
|
* Make get_room_version use cached get_room_version_id. (#11808)lukasdenk2022-03-021-14/+13
|
* 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-301-14/+0
| | | To improve type hints throughout the code.
* Type hint the constructors of the data store classes (#11555)Sean Quah2021-12-131-4/+23
|
* Add type hints for most `HomeServer` parameters (#11095)Sean Quah2021-10-221-4/+7
|
* Fix remove_stale_pushers job on SQLite. (#10843)reivilibre2021-09-201-2/+2
|
* Make historical events discoverable from backfill for servers without any ↵Eric Eastwood2021-07-281-11/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scrollback history (MSC2716) (#10245) * Make historical messages available to federated servers Part of MSC2716: https://github.com/matrix-org/matrix-doc/pull/2716 Follow-up to https://github.com/matrix-org/synapse/pull/9247 * Debug message not available on federation * Add base starting insertion point when no chunk ID is provided * Fix messages from multiple senders in historical chunk Follow-up to https://github.com/matrix-org/synapse/pull/9247 Part of MSC2716: https://github.com/matrix-org/matrix-doc/pull/2716 --- Previously, Synapse would throw a 403, `Cannot force another user to join.`, because we were trying to use `?user_id` from a single virtual user which did not match with messages from other users in the chunk. * Remove debug lines * Messing with selecting insertion event extremeties * Move db schema change to new version * Add more better comments * Make a fake requester with just what we need See https://github.com/matrix-org/synapse/pull/10276#discussion_r660999080 * Store insertion events in table * Make base insertion event float off on its own See https://github.com/matrix-org/synapse/pull/10250#issuecomment-875711889 Conflicts: synapse/rest/client/v1/room.py * Validate that the app service can actually control the given user See https://github.com/matrix-org/synapse/pull/10276#issuecomment-876316455 Conflicts: synapse/rest/client/v1/room.py * Add some better comments on what we're trying to check for * Continue debugging * Share validation logic * Add inserted historical messages to /backfill response * Remove debug sql queries * Some marker event implemntation trials * Clean up PR * Rename insertion_event_id to just event_id * Add some better sql comments * More accurate description * Add changelog * Make it clear what MSC the change is part of * Add more detail on which insertion event came through * Address review and improve sql queries * Only use event_id as unique constraint * Fix test case where insertion event is already in the normal DAG * Remove debug changes * Switch to chunk events so we can auth via power_levels Previously, we were using `content.chunk_id` to connect one chunk to another. But these events can be from any `sender` and we can't tell who should be able to send historical events. We know we only want the application service to do it but these events have the sender of a real historical message, not the application service user ID as the sender. Other federated homeservers also have no indicator which senders are an application service on the originating homeserver. So we want to auth all of the MSC2716 events via power_levels and have them be sent by the application service with proper PL levels in the room. * Switch to chunk events for federation * Add unstable room version to support new historical PL * Fix federated events being rejected for no state_groups Add fix from https://github.com/matrix-org/synapse/pull/10439 until it merges. * Only connect base insertion event to prev_event_ids Per discussion with @erikjohnston, https://matrix.to/#/!UytJQHLQYfvYWsGrGY:jki.re/$12bTUiObDFdHLAYtT7E-BvYRp3k_xv8w0dUQHibasJk?via=jki.re&via=matrix.org * Make it possible to get the room_version with txn * Allow but ignore historical events in unsupported room version See https://github.com/matrix-org/synapse/pull/10245#discussion_r675592489 We can't reject historical events on unsupported room versions because homeservers without knowledge of MSC2716 or the new room version don't reject historical events either. Since we can't rely on the auth check here to stop historical events on unsupported room versions, I've added some additional checks in the processing/persisting code (`synapse/storage/databases/main/events.py` -> `_handle_insertion_event` and `_handle_chunk_event`). I've had to do some refactoring so there is method to fetch the room version by `txn`. * Move to unique index syntax See https://github.com/matrix-org/synapse/pull/10245#discussion_r675638509 * High-level document how the insertion->chunk lookup works * Remove create_event fallback for room_versions See https://github.com/matrix-org/synapse/pull/10245/files#r677641879 * Use updated method name
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Bugbear: Add Mutable Parameter fixes (#9682)Jonathan de Jong2021-04-081-2/+4
| | | | | | | Part of #9366 Adds in fixes for B006 and B008, both relating to mutable parameter lint errors. Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-6/+5
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Simplify super() calls to Python 3 syntax. (#8344)Patrick Cloke2020-09-181-3/+3
| | | | | | | This converts calls like super(Foo, self) -> super(). Generated with: sed -i "" -Ee 's/super\([^\(]+\)/super()/g' **/*.py
* Convert state and stream stores and related code to async (#8194)Patrick Cloke2020-08-281-9/+10
|
* Convert simple_select_one and simple_select_one_onecol to async (#8162)Patrick Cloke2020-08-261-2/+2
|
* Convert misc database code to async (#8087)Patrick Cloke2020-08-141-3/+2
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-0/+509