summary refs log tree commit diff
path: root/synapse/storage/databases/main/presence.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix sync waiting for an invalid token from the "future" (#17386)Erik Johnston2024-07-021-5/+5
| | | | | | | | | | | | | 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.
* Move towards using `MultiWriterIdGenerator` everywhere (#17226)Erik Johnston2024-05-291-17/+10
| | | | | | | | | | | | | | | 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.
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-231-0/+1
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Update license headersPatrick Cloke2023-11-211-10/+16
|
* Use _invalidate_cache_and_stream_bulk in more places. (#16616)Patrick Cloke2023-11-091-4/+5
| | | | | 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_many_batch, simple_select_many_txn to tuples. (#16444)Patrick Cloke2023-10-111-18/+33
|
* Convert simple_select_list_paginate_txn to return tuples. (#16433)Patrick Cloke2023-10-061-19/+39
|
* Remove manys calls to cursor_to_dict (#16431)Patrick Cloke2023-10-051-5/+13
| | | | | | | | | | 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.
* Return immutable objects for cachedList decorators (#16350)Patrick Cloke2023-09-191-2/+12
|
* 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
* Always notify replication when a stream advances (#14877)Erik Johnston2023-01-201-1/+2
| | | This ensures that all other workers are told about stream updates in a timely manner, without having to remember to manually poke replication.
* Update all stream IDs after processing replication rows (#14723)Nick Mills-Barrett2023-01-041-1/+7
| | | | | | | | | | | | | | This creates a new store method, `process_replication_position` that is called after `process_replication_rows`. By moving stream ID advances here this guarantees any relevant cache invalidations will have been applied before the stream is advanced. This avoids race conditions where Python switches between threads mid way through processing the `process_replication_rows` method where stream IDs may be advanced before caches are invalidated due to class resolution ordering. See this comment/issue for further discussion: https://github.com/matrix-org/synapse/issues/14158#issuecomment-1344048703
* Revert "Make all `process_replication_rows` methods async (#13304)" (#13312)Erik Johnston2022-07-181-4/+2
| | | This reverts commit 5d4028f217f178fcd384d5bfddd92225b4e78c51.
* Make all `process_replication_rows` methods async (#13304)Nick Mills-Barrett2022-07-171-2/+4
| | | | | More prep work for asyncronous caching, also makes all process_replication_rows methods consistent (presence handler already is so). Signed off by Nick @ Beeper (@Fizzadar)
* 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*.
* Add some type hints to datastore (#12485)Dirk Klimpel2022-04-271-4/+15
|
* Add type hints to `synapse/storage/databases/main` (#11984)Dirk Klimpel2022-02-211-20/+41
|
* Replace uses of simple_insert_many with simple_insert_many_values. (#11742)Patrick Cloke2022-01-131-11/+22
| | | | This should be (slightly) more efficient and it is simpler to have a single method for inserting multiple values.
* checks for generators in database functions (#11564)Richard van der Hoff2021-12-131-3/+2
| | | | | 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-131-3/+3
|
* Fix providing a `RoomStreamToken` instance to ↵Andrew Morgan2021-11-021-1/+1
| | | | | `_notify_app_services_ephemeral` (#11137) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add a partial index to `presence_stream` to speed up startups (#10748)Sean2021-09-031-1/+22
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Fix bug when running presence off master (#10149)Erik Johnston2021-06-111-1/+1
| | | Hopefully fixes #10027.
* Fixed removal of new presence stream states (#10014)Marek Matys2021-05-211-9/+9
| | | | | | | | | Fixes: https://github.com/matrix-org/synapse/issues/9962 This is a fix for above problem. I fixed it by swaping the order of insertion of new records and deletion of old ones. This ensures that we don't delete fresh database records as we do deletes before inserts. Signed-off-by: Marek Matys <themarcq@gmail.com>
* Use a database table to hold the users that should have full presence sent ↵Andrew Morgan2021-05-181-1/+57
| | | | to them, instead of something in-memory (#9823)
* Split presence out of master (#9820)Erik Johnston2021-04-231-2/+90
|
* 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>`
* Add a storage method for returning all current presence from all users (#9650)Andrew Morgan2021-03-251-1/+59
| | | | | | | Split off from https://github.com/matrix-org/synapse/pull/9491 Adds a storage method for getting the current presence of all local users, optionally excluding those that are offline. This will be used by the code in #9491 when a PresenceRouter module informs Synapse that a given user should have `"ALL"` user presence updates routed to them. Specifically, it is used here: https://github.com/matrix-org/synapse/blob/b588f16e391d664b11f43257eabf70663f0c6d59/synapse/handlers/presence.py#L1131-L1133 Note that there is a `get_all_presence_updates` function just above. That function is intended to walk up the table through stream IDs, and is primarily used by the presence replication stream. I could possibly make use of it in the PresenceRouter-related code, but it would be a bit of a bodge.
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-1/+3
| | | | | | | - 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
* Use `async with` for ID gens (#8383)Erik Johnston2020-09-231-2/+2
| | | This will allow us to hit the DB after we've finished using the generated stream ID.
* Make StreamIdGen `get_next` and `get_next_mult` async (#8161)Erik Johnston2020-08-251-1/+1
| | | | This is mainly so that `StreamIdGenerator` and `MultiWriterIdGenerator` will have the same interface, allowing them to be used interchangeably.
* Convert stream database to async/await. (#8074)Patrick Cloke2020-08-171-1/+1
|
* Remove some unused database functions. (#8085)Patrick Cloke2020-08-141-21/+0
|
* Convert misc database code to async (#8087)Patrick Cloke2020-08-141-6/+3
|
* Convert appservice, group server, profile and more databases to async (#8066)Patrick Cloke2020-08-121-5/+2
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-0/+186