summary refs log tree commit diff
path: root/synapse/storage/database.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use the parent's logging context name for runWithConnection. (#9895)Patrick Cloke2021-04-281-1/+3
| | | | | This fixes a regression where the logging context for runWithConnection was reported as runWithConnection instead of the connection name, e.g. "POST-XYZ".
* Remove various bits of compatibility code for Python <3.6 (#9879)Andrew Morgan2021-04-271-9/+6
| | | I went through and removed a bunch of cruft that was lying around for compatibility with old Python versions. This PR also will now prevent Synapse from starting unless you're running Python 3.6+.
* Remove `synapse.types.Collection` (#9856)Richard van der Hoff2021-04-221-1/+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>`
* Bump black configuration to target py36 (#9781)Dan Callahan2021-04-131-4/+4
| | | Signed-off-by: Dan Callahan <danc@element.io>
* Bugbear: Add Mutable Parameter fixes (#9682)Jonathan de Jong2021-04-081-6/+14
| | | | | | | 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>
* remove unused param on `make_tuple_comparison_clause`Richard van der Hoff2021-04-081-4/+1
|
* Drop support for sqlite<3.22 as wellRichard van der Hoff2021-04-081-55/+7
|
* Add a storage method for returning all current presence from all users (#9650)Andrew Morgan2021-03-251-2/+9
| | | | | | | 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.
* Enable addtional flake8-bugbear linting checks. (#9659)Jonathan de Jong2021-03-241-1/+1
|
* Refactor to ensure we call check_consistency (#9470)Erik Johnston2021-02-241-12/+4
| | | The idea here is to stop people forgetting to call `check_consistency`. Folks can still just pass in `None` to the new args in `build_sequence_generator`, but hopefully they won't.
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-8/+19
| | | | | | | - 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
* Update type hints for Cursor to match PEP 249. (#9299)Jonathan de Jong2021-02-051-5/+9
|
* Use execute_batch in more places (#9188)Erik Johnston2021-01-211-0/+6
| | | | | * Use execute_batch in more places * Newsfile
* Use execute_batch instead of executemany in places (#9181)Erik Johnston2021-01-211-3/+2
| | | `execute_batch` does fewer round trips in postgres than `executemany`, but does not give a correct `txn.rowcount` result after.
* Fix chain cover background update to work with split out event persisters ↵Erik Johnston2021-01-141-0/+11
| | | | (#9115)
* Use a chain cover index to efficiently calculate auth chain difference (#8868)Erik Johnston2021-01-111-4/+18
|
* Add type hints to the logging context code. (#8939)Patrick Cloke2021-01-051-3/+5
|
* Enable reconnection in DB pool (#8726)Erik Johnston2020-11-121-1/+6
| | | | | | `adbapi.ConnectionPool` let's you turn on auto reconnect of DB connections. This is off by default. As far as I can tell if its not enabled dead connections never get removed from the pool. Maybe helps #8574
* Tell Black to format code for Python 3.5 (#8664)Dan Callahan2020-10-271-2/+2
| | | | | | | | This allows trailing commas in multi-line arg lists. Minor, but we might as well keep our formatting current with regard to our minimum supported Python version. Signed-off-by: Dan Callahan <danc@element.io>
* Pre-emptively fix synapse.storage.types.Connection for future mypy release ↵Jonathan de Jong2020-10-171-1/+1
| | | | | (#8577) Fix the Connection protocol according to typeshed's assertions about sqlite3.Connection
* Use autocommit mode for single statement DB functions. (#8542)Erik Johnston2020-10-141-8/+91
| | | | | | | | | | | | | Autocommit means that we don't wrap the functions in transactions, and instead get executed directly. Introduced in #8456. This will help: 1. reduce the number of `could not serialize access due to concurrent delete` errors that we see (though there are a few functions that often cause serialization errors that we don't fix here); 2. improve the DB performance, as it no longer needs to deal with the overhead of `REPEATABLE READ` isolation levels; and 3. improve wall clock speed of these functions, as we no longer need to send `BEGIN` and `COMMIT` to the DB. Some notes about the differences between autocommit mode and our default `REPEATABLE READ` transactions: 1. Currently `autocommit` only applies when using PostgreSQL, and is ignored when using SQLite (due to silliness with [Twisted DB classes](https://twistedmatrix.com/trac/ticket/9998)). 2. Autocommit functions may get retried on error, which means they can get applied *twice* (or more) to the DB (since they are not in a transaction the previous call would not get rolled back). This means that the functions need to be idempotent (or otherwise not care about being called multiple times). Read queries, simple deletes, and updates/upserts that replace rows (rather than generating new values from existing rows) are all idempotent. 3. Autocommit functions no longer get executed in [`REPEATABLE READ`](https://www.postgresql.org/docs/current/transaction-iso.html) isolation level, and so data can change queries, which is fine for single statement queries.
* Reduce serialization errors in MultiWriterIdGen (#8456)Erik Johnston2020-10-071-6/+63
| | | | | | We call `_update_stream_positions_table_txn` a lot, which is an UPSERT that can conflict in `REPEATABLE READ` isolation level. Instead of doing a transaction consisting of a single query we may as well run it outside of a transaction.
* Add logging on startup/shutdown (#8448)Erik Johnston2020-10-021-15/+74
| | | | | This is so we can tell what is going on when things are taking a while to start up. The main change here is to ensure that transactions that are created during startup get correctly logged like normal transactions.
* Catch-up after Federation Outage (split, 1) (#8230)reivilibre2020-09-041-2/+2
| | | Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
* Fix type signature in simple_select_one_onecol and friends (#8241)reivilibre2020-09-041-10/+7
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-2/+2
|
* Add an overload for simple_select_one_onecol_txn. (#8235)Patrick Cloke2020-09-021-0/+24
|
* Convert runInteraction to async/await (#8156)Patrick Cloke2020-09-021-15/+14
|
* Add StreamStore to mypy (#8232)Erik Johnston2020-09-021-0/+34
|
* Convert simple_delete to async/await. (#8191)Patrick Cloke2020-08-271-8/+55
|
* simple_search_list_txn should return None, not 0. (#8187)Patrick Cloke2020-08-271-4/+3
|
* Convert additional database methods to async (select list, search, ↵Patrick Cloke2020-08-271-62/+37
| | | | insert_many, delete_*) (#8168)
* Convert simple_update* and simple_select* to async (#8173)Patrick Cloke2020-08-271-14/+15
|
* Convert simple_select_one and simple_select_one_onecol to async (#8162)Patrick Cloke2020-08-261-6/+30
|
* Add more types to synapse.storage.database. (#8127)Patrick Cloke2020-08-201-219/+358
|
* Convert runWithConnection to async. (#8121)Patrick Cloke2020-08-191-14/+13
|
* Convert some of the general database methods to async (#8100)Patrick Cloke2020-08-171-14/+9
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-1/+1
|
* Move some log lines from default logger to sql/transaction loggers (#7952)Andrew Morgan2020-07-281-8/+10
| | | Idea from matrix-org/synapse-dinsic#49
* Replace all remaining six usage with native Python 3 equivalents (#7704)Dagfinn Ilmari Mannsåker2020-06-161-2/+1
|
* Replace iteritems/itervalues/iterkeys with native versions. (#7692)Patrick Cloke2020-06-151-7/+6
|
* Replace device_27_unique_idx bg update with a fg one (#7562)Richard van der Hoff2020-05-261-1/+0
| | | | | | The bg update never managed to complete, because it kept being interrupted by transactions which want to take a lock. Just doing it in the foreground isn't that bad, and is a good deal simpler.
* Remove `exception_to_unicode`Richard van der Hoff2020-05-151-12/+3
| | | | this is a no-op on python 3.
* Fix new flake8 errors (#7470)Erik Johnston2020-05-121-2/+2
|
* use an upsert to update device_lists_outbound_last_successRichard van der Hoff2020-05-061-0/+1
|
* Better type annotations for simple_upsert_txnRichard van der Hoff2020-05-061-30/+43
| | | | most of these params don't really need to be lists.
* bg update to clear out duplicate outbound_device_list_pokes (#7193)Richard van der Hoff2020-04-071-1/+82
| | | | We seem to have some duplicates, which could do with being cleared out.
* Clean up some LoggingContext stuff (#7120)Richard van der Hoff2020-03-241-6/+5
| | | | | | | | | | | | | | | | | | | | | | | * Pull Sentinel out of LoggingContext ... and drop a few unnecessary references to it * Factor out LoggingContext.current_context move `current_context` and `set_context` out to top-level functions. Mostly this means that I can more easily trace what's actually referring to LoggingContext, but I think it's generally neater. * move copy-to-parent into `stop` this really just makes `start` and `stop` more symetric. It also means that it behaves correctly if you manually `set_log_context` rather than using the context manager. * Replace `LoggingContext.alive` with `finished` Turn `alive` into `finished` and make it a bit better defined.
* Hopefully mypy is happy nowBrendan Abolivier2020-03-101-2/+8
|
* Add some type annotations in `synapse.storage` (#6987)Richard van der Hoff2020-02-271-59/+84
| | | | | I cracked, and added some type definitions in synapse.storage.
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-2/+2
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Minor perf fixes to `get_auth_chain_ids`.Erik Johnston2020-02-191-1/+1
|
* Reduce performance logging to DEBUG (#6833)Michael Kaye2020-02-051-1/+1
| | | | | * Reduce tnx performance logging to DEBUG * Changelog.d
* Add database config class (#6513)Erik Johnston2019-12-181-3/+42
| | | | | This encapsulates config for a given database and is the way to get new connections.
* Pass Database into the data storeErik Johnston2019-12-061-22/+16
|
* Merge branch 'develop' of github.com:matrix-org/synapse into ↵Erik Johnston2019-12-061-23/+28
| | | | erikj/make_database_class
* Remove unused varErik Johnston2019-12-061-2/+0
|
* Move background update handling out of storeErik Johnston2019-12-051-0/+3
|
* CommentsErik Johnston2019-12-051-0/+5
|
* Move DB pool and helper functions into dedicated Database classErik Johnston2019-12-051-0/+1485