summary refs log tree commit diff
path: root/tests/storage/databases (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix database performance of read/write worker locks (#16061)Erik Johnston2023-08-171-3/+4
| | | | | | | We were seeing serialization errors when taking out multiple read locks. The transactions were retried, so isn't causing any failures. Introduced in #15782.
* Add ability to wait for locks and add locks to purge history / room deletion ↵Erik Johnston2023-07-311-0/+52
| | | | | (#15791) c.f. #13476
* Add basic read/write lock (#15782)Erik Johnston2023-07-051-1/+282
|
* Prefill events after invalidate not before when persisting events (#15758)Jason Little2023-06-141-0/+49
| | | | | Fixes #15757
* Clear event caches when we purge history (#15609)Erik Johnston2023-06-081-4/+4
| | | | | | | This should help a little with #13476 --------- Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-223-3/+1
|
* Add final type hint to tests.unittest. (#15072)Patrick Cloke2023-02-141-0/+1
| | | | Adds a return type to HomeServerTestCase.make_homeserver and deal with any variables which are no longer Any.
* Attempt to delete more duplicate rows in receipts_linearized table. (#14915)Patrick Cloke2023-02-011-1/+3
| | | | | | | | | The previous assumption was that the stream_id column was unique (for a room ID, receipt type, user ID tuple), but this turned out to be incorrect. Now find the max stream ID, then map this back to a database-specific row identifier and delete other rows which match the (room ID, receipt type, user ID) tuple, but *not* the row ID.
* Skip processing stats for broken rooms. (#14873)Patrick Cloke2023-01-231-34/+54
| | | | | | | * Skip processing stats for broken rooms. * Newsfragment * Use a custom exception.
* Require types in tests.storage. (#14646)Patrick Cloke2022-12-095-31/+42
| | | | Adds missing type hints to `tests.storage` package and does not allow untyped definitions.
* Fix background updates failing to add unique indexes on receipts (#14453)Sean Quah2022-11-161-0/+209
| | | | | | | | | | | | | | | | | | | | | | As part of the database migration to support threaded receipts, there is a possible window in between `73/08thread_receipts_non_null.sql.postgres` removing the original unique constraints on `receipts_linearized` and `receipts_graph` and the `reeipts_linearized_unique_index` and `receipts_graph_unique_index` background updates from `72/08thread_receipts.sql` completing where the unique constraints on `receipts_linearized` and `receipts_graph` are missing. Any emulated upserts on these tables must therefore be performed with a lock held, otherwise duplicate rows can end up in the tables when there are concurrent emulated upserts. Fix the missing lock. Note that emulated upserts no longer happen by default on sqlite, since the minimum supported version of sqlite supports native upserts by default now. Finally, clean up any duplicate receipts that may have crept in before trying to create the `receipts_graph_unique_index` and `receipts_linearized_unique_index` unique indexes. Signed-off-by: Sean Quah <seanq@matrix.org>
* Remove `_get_events_cache` check optimisation from `_have_seen_events_dict` ↵Andrew Morgan2022-10-181-12/+0
| | | | (#14161)
* Fix `have_seen_event` cache not being invalidated (#13863)Eric Eastwood2022-09-271-48/+104
| | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/13856 Fix https://github.com/matrix-org/synapse/issues/13865 > Discovered while trying to make Synapse fast enough for [this MSC2716 test for importing many batches](https://github.com/matrix-org/complement/pull/214#discussion_r741678240). As an example, disabling the `have_seen_event` cache saves 10 seconds for each `/messages` request in that MSC2716 Complement test because we're not making as many federation requests for `/state` (speeding up `have_seen_event` itself is related to https://github.com/matrix-org/synapse/issues/13625) > > But this will also make `/messages` faster in general so we can include it in the [faster `/messages` milestone](https://github.com/matrix-org/synapse/milestone/11). > > *-- https://github.com/matrix-org/synapse/issues/13856* ### The problem `_invalidate_caches_for_event` doesn't run in monolith mode which means we never even tried to clear the `have_seen_event` and other caches. And even in worker mode, it only runs on the workers, not the master (AFAICT). Additionally there was bug with the key being wrong so `_invalidate_caches_for_event` never invalidates the `have_seen_event` cache even when it does run. Because we were using the `@cachedList` wrong, it was putting items in the cache under keys like `((room_id, event_id),)` with a `set` in a `set` (ex. `(('!TnCIJPKzdQdUlIyXdQ:test', '$Iu0eqEBN7qcyF1S9B3oNB3I91v2o5YOgRNPwi_78s-k'),)`) and we we're trying to invalidate with just `(room_id, event_id)` which did nothing.
* Rename the `EventFormatVersions` enum values so that they line up with room ↵reivilibre2022-09-071-1/+1
| | | | version numbers. (#13706)
* Async get event cache prep (#13242)Nick Mills-Barrett2022-07-151-4/+4
| | | | | Some experimental prep work to enable external event caching based on #9379 & #12955. Doesn't actually move the cache at all, just lays the groundwork for async implemented caches. Signed off by Nick @ Beeper (@Fizzadar)
* Implement MSC3827: Filtering of `/publicRooms` by room type (#13031)Šimon Brandner2022-06-291-0/+69
| | | | Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* LockStore: fix acquiring a lock via `LockStore.try_acquire_lock` (#12832)Sumner Evans2022-05-301-0/+54
| | | Signed-off-by: Sumner Evans <sumner@beeper.com>
* Track in memory events using weakrefs (#10533)Erik Johnston2022-05-171-0/+25
|
* Add a consistency check on events read from the database (#12620)Richard van der Hoff2022-05-031-22/+37
| | | | | | | 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.
* Handle cancellation in `EventsWorkerStore._get_events_from_cache_or_db` (#12529)Sean Quah2022-04-251-2/+119
| | | | | | | | 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>
* Add type hints for `tests/unittest.py`. (#12347)Richard van der Hoff2022-04-011-4/+4
| | | In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
* Back out in-flight state caching changes. (#12126)reivilibre2022-03-021-454/+0
|
* Order in-flight state group queries in biggest-first order (#11610)reivilibre2022-03-011-1/+103
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Replace assertEquals and friends with non-deprecated versions. (#12092)Patrick Cloke2022-02-281-6/+6
|
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-234-6/+6
| | | | | | | 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/+69
|
* Add more tests for in-flight state query duplication. (#12033)reivilibre2022-02-221-21/+171
|
* Track and deduplicate in-flight requests to `_get_state_for_groups`. (#10870)reivilibre2022-02-181-0/+133
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Track ongoing event fetches correctly (again) (#11376)Sean Quah2021-11-261-1/+138
| | | | | | | | | | | | | 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-251-2/+2
| | | | | (#11421) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Delete messages for hidden devices from `device_inbox` (#11199)Dirk Klimpel2021-11-021-0/+74
|
* Delete messages from `device_inbox` table when deleting device (#10969)Dirk Klimpel2021-10-271-0/+90
| | | Fixes: #9346
* Don't drop user dir deltas when server leaves room (#10982)David Robertson2021-10-061-6/+1
| | | | | | | | | Fix a long-standing bug where a batch of user directory changes would be silently dropped if the server left a room early in the batch. * Pull out `wait_for_background_update` in tests Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Populate `rooms.creator` field for easy lookup (#10697)Eric Eastwood2021-09-011-0/+98
| | | | | | Part of https://github.com/matrix-org/synapse/pull/10566 - Fill in creator whenever we insert into the rooms table - Add background update to backfill any missing creator values
* Flatten the synapse.rest.client package (#10600)reivilibre2021-08-171-1/+1
|
* Improve event caching code (#10119)Erik Johnston2021-08-041-0/+50
| | | | Ensure we only load an event from the DB once when the same event is requested multiple times at once.
* Fix dropping locks on shut down (#10433)Erik Johnston2021-07-201-0/+13
|
* Add a distributed lock (#10269)Erik Johnston2021-06-291-0/+100
| | | This adds a simple best effort locking mechanism that works cross workers.
* add a cache to have_seen_event (#9953)Richard van der Hoff2021-06-013-0/+122
Empirically, this helped my server considerably when handling gaps in Matrix HQ. The problem was that we would repeatedly call have_seen_events for the same set of (50K or so) auth_events, each of which would take many minutes to complete, even though it's only an index scan.