summary refs log tree commit diff
path: root/synapse/storage/persist_events.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename storage classes (#12913)Erik Johnston2022-05-311-1124/+0
|
* Avoid attempting to delete push actions for remote users. (#12879)Patrick Cloke2022-05-261-1/+1
| | | | Remote users will never have push actions, so we can avoid a database round-trip/transaction completely.
* Reduce the number of "untyped defs" (#12716)David Robertson2022-05-121-8/+13
|
* Refactor `EventContext` (#12689)Erik Johnston2022-05-101-35/+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
* remove constantly lib use and switch to enums. (#12624)andrew do2022-05-041-2/+2
|
* Resync state after partial-state join (#12394)Richard van der Hoff2022-04-121-0/+56
| | | | | 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 cache for `get_membership_from_event_ids` (#12272)Erik Johnston2022-03-251-4/+11
| | | | | 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>
* Minor typing fixes for `synapse/storage/persist_events.py` (#12069)Sean Quah2022-02-251-13/+12
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Refactor `backfilled` into specific behavior function arguments ↵Eric Eastwood2021-11-291-1/+2
| | | | | | | | | | | | | | | (`_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.
* Add type hints for most `HomeServer` parameters (#11095)Sean Quah2021-10-221-1/+5
|
* Generics for `ObservableDeferred` (#10491)Richard van der Hoff2021-07-281-1/+3
| | | | | Now that `Deferred` is a generic class, let's update `ObeservableDeferred` to follow suit.
* Use inline type hints in `http/federation/`, `storage/` and `util/` (#10381)Jonathan de Jong2021-07-151-9/+7
|
* Fix persist_events to stop leaking opentracing contexts (#10193)Richard van der Hoff2021-06-171-1/+1
|
* Make opentracing trace into event persistence (#10134)Richard van der Hoff2021-06-161-5/+41
| | | | | | | | | | | | | | * Trace event persistence When we persist a batch of events, set the parent opentracing span to the that from the request, so that we can trace all the way in. * changelog * When we force tracing, set a baggage item ... so that we can check again later. * Link in both directions between persist_events spans
* Refactor `EventPersistenceQueue` (#10145)Richard van der Hoff2021-06-141-77/+88
| | | some cleanup, pulled out of #10134.
* Remove `synapse.types.Collection` (#9856)Richard van der Hoff2021-04-221-2/+1
| | | This is no longer required, since we have dropped support for Python 3.5.
* 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>`
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-4/+8
| | | | | | | - 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
* Try and drop stale extremities. (#8929)Erik Johnston2020-12-181-16/+184
| | | | If we see stale extremities while persisting events, and notice that they don't change the result of state resolution, we drop them.
* Fix message duplication if something goes wrong after persisting the event ↵Erik Johnston2020-10-131-13/+83
| | | | | (#8476) Should fix #3365.
* Remove stream ordering from Metadata dict (#8452)Richard van der Hoff2020-10-051-0/+2
| | | | | | | | There's no need for it to be in the dict as well as the events table. Instead, we store it in a separate attribute in the EventInternalMetadata object, and populate that on load. This means that we can rely on it being correctly populated for any event which has been persited to the database.
* Various clean ups to room stream tokens. (#8423)Erik Johnston2020-09-291-3/+2
|
* Mypy fixes for `synapse.handlers.federation` (#8422)Richard van der Hoff2020-09-291-1/+1
| | | For some reason, an apparently unrelated PR upset mypy about this module. Here are a number of little fixes.
* Add EventStreamPosition type (#8388)Erik Johnston2020-09-241-5/+9
| | | | | | | | | | | | | | The idea is to remove some of the places we pass around `int`, where it can represent one of two things: 1. the position of an event in the stream; or 2. a token that partitions the stream, used as part of the stream tokens. The valid operations are then: 1. did a position happen before or after a token; 2. get all events that happened before or after a token; and 3. get all events between two tokens. (Note that we don't want to allow other operations as we want to change the tokens to be vector clocks rather than simple ints)
* Make `StreamToken.room_key` be a `RoomStreamToken` instance. (#8281)Erik Johnston2020-09-111-6/+10
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-2/+2
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-3/+3
|
* Convert storage layer to async/await. (#7963)Patrick Cloke2020-07-281-22/+18
|
* Convert state resolution to async/await (#7942)Patrick Cloke2020-07-241-1/+4
|
* Generate real events when we reject invites (#7804)Richard van der Hoff2020-07-091-6/+0
| | | | | | | | Fixes #2181. The basic premise is that, when we fail to reject an invite via the remote server, we can generate our own out-of-band leave event and persist it as an outlier, so that we have something to send to the client.
* Replace all remaining six usage with native Python 3 equivalents (#7704)Dagfinn Ilmari Mannsåker2020-06-161-2/+0
|
* Replace iteritems/itervalues/iterkeys with native versions. (#7692)Patrick Cloke2020-06-151-4/+3
|
* Add option to move event persistence off master (#7517)Erik Johnston2020-05-221-0/+6
|
* Fix bug in persist events when dealing with non member types. (#7548)Erik Johnston2020-05-211-2/+2
| | | | | `_is_server_still_joined` will throw if it is given state updates with non-user ID state keys with local user leaves. This is actually rarely a problem since local leaves almost always get persisted by themselves. (I discovered this on a branch that was otherwise broken, so I haven't seen this in the wild)
* Shuffle persist event data store functions. (#7440)Erik Johnston2020-05-131-20/+7
| | | | | | | | | | The aim here is to get to a stage where we have a `PersistEventStore` that holds all the write methods used during event persistence, so that we can take that class out of the `DataStore` mixin and instansiate it separately. This will allow us to instansiate it on processes other than master, while also ensuring it is only available on processes that are configured to write to events stream. This is a bit of an architectural change, where we end up with multiple classes per data store (rather than one per data store we have now). We end up having: 1. Storage classes that provide high level APIs that can talk to multiple data stores. 2. Data store modules that consist of classes that must point at the same database instance. 3. Classes in a data store that can be instantiated on processes depending on config.
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-4/+4
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Increase DB/CPU perf of `_is_server_still_joined` check. (#6936)Erik Johnston2020-02-191-15/+28
| | | | | | | | | | | | | | | | | | | | | | | | * Increase DB/CPU perf of `_is_server_still_joined` check. For rooms with large amount of state a single user leaving could cause us to go and load a lot of membership events and then pull out membership state in a large number of batches. * Newsfile * Update synapse/storage/persist_events.py Co-Authored-By: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Fix adding if too soon * Update docstring * Review comments * Woops typo Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Reduce amount of logging at INFO level. (#6862)Erik Johnston2020-02-061-1/+1
| | | | | | | | A lot of the things we log at INFO are now a bit superfluous, so lets make them DEBUG logs to reduce the amount we log by default. Co-Authored-By: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Brendan Abolivier <github@brendanabolivier.com>
* s/get_room_version/get_room_version_id/Richard van der Hoff2020-01-311-1/+1
| | | | | ... to make way for a forthcoming get_room_version which returns a RoomVersion object.
* When server leaves room check for stale device lists. (#6801)Erik Johnston2020-01-301-4/+47
| | | | | | | | | When a server leaves a room it may stop sharing a room with remote users, and thus not get any updates to their device lists. So we need to check for this case and delete those device lists from the cache. We don't need to do this if we stop sharing a room because the remote user leaves the room, because we track that case via looking at membership changes.
* Delete current state when server leaves a room (#6792)Erik Johnston2020-01-291-3/+86
| | | | | | Otherwise its just stale data, which may get deleted later anyway so can't be relied on. It's also a bit of a shotgun if we're trying to get the current state of a room we're not in.
* Add a DeltaState to track changes to be made to current state (#6716)Erik Johnston2020-01-201-55/+68
|
* Split state groups into a separate data store (#6296)Erik Johnston2019-12-201-1/+1
|
* Merge pull request #6294 from matrix-org/erikj/add_state_storageErik Johnston2019-10-311-1/+1
|\ | | | | Add StateGroupStorage interface
| * Add StateGroupStorage interfaceErik Johnston2019-10-301-1/+1
| |
* | fix delete_existing for _persist_events (#6300)Richard van der Hoff2019-10-301-4/+1
|/ | | this is part of _retry_on_integrity_error, so should only be on _persist_events_and_state_updates
* Review commentsErik Johnston2019-10-301-3/+10
|
* Add DataStores and Storage classes.Erik Johnston2019-10-231-3/+4
|
* Move persist_events out from main data store.Erik Johnston2019-10-231-0/+644
This is in preparation for splitting out of state_groups_state from the main store into it own one, as persisting events depends on calculating state.