anonymousland-synapse/synapse
Erik Johnston 19b15d63e8
Use autocommit mode for single statement DB functions. (#8542)
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.
2020-10-14 15:50:59 +01:00
..
_scripts Remove obsolete __future__ imports (#8337) 2020-09-17 08:37:01 -04:00
api Do not assume that account data is of the correct form. (#8454) 2020-10-05 09:28:05 -04:00
app Fix not sending events over federation when using sharded event persisters (#8536) 2020-10-14 13:27:51 +01:00
appservice Add type hints to response cache. (#8507) 2020-10-09 11:35:11 -04:00
config Increase default max_upload_size from 10M to 50M (#8502) 2020-10-09 16:58:23 +01:00
crypto Fix occasional "Re-starting finished log context" from keyring (#8398) 2020-09-25 12:29:54 +01:00
events Make sure a retention policy is a state event (#8527) 2020-10-14 12:00:52 +01:00
federation Fix not sending events over federation when using sharded event persisters (#8536) 2020-10-14 13:27:51 +01:00
groups Simplify super() calls to Python 3 syntax. (#8344) 2020-09-18 09:56:44 -04:00
handlers Fix not sending events over federation when using sharded event persisters (#8536) 2020-10-14 13:27:51 +01:00
http Don't bother responding to client requests that have already disconnected (#8465) 2020-10-06 10:03:39 +01:00
logging Enable mypy checking for unreachable code and fix instances. (#8432) 2020-10-01 08:09:18 -04:00
metrics Rewrite BucketCollector 2020-09-30 16:49:15 +01:00
module_api Allow modules to create and send events into rooms (#8479) 2020-10-09 13:46:36 +01:00
push Fix not sending events over federation when using sharded event persisters (#8536) 2020-10-14 13:27:51 +01:00
replication Fix message duplication if something goes wrong after persisting the event (#8476) 2020-10-13 12:07:56 +01:00
res/templates Convert additional templates to Jinja (#8444) 2020-10-02 11:15:53 +01:00
rest Add correct M_BAD_JSON error code to /profile/{userId}/displayname (#8517) 2020-10-14 11:24:58 +01:00
server_notices Stop sub-classing object (#8249) 2020-09-04 06:54:56 -04:00
spam_checker_api Combine SpamCheckerApi with the more generic ModuleApi. (#8464) 2020-10-07 12:03:26 +01:00
state Enable mypy checking for unreachable code and fix instances. (#8432) 2020-10-01 08:09:18 -04:00
static Clean-up the fallback login code. (#7657) 2020-06-10 09:50:39 -04:00
storage Use autocommit mode for single statement DB functions. (#8542) 2020-10-14 15:50:59 +01:00
streams Make token serializing/deserializing async (#8427) 2020-09-30 20:29:19 +01:00
util Add type hints to response cache. (#8507) 2020-10-09 11:35:11 -04:00
__init__.py 1.21.1 2020-10-13 10:27:16 +01:00
event_auth.py Ensure that event.redacts is the proper type before handling it (#8457) 2020-10-05 10:24:17 -04:00
notifier.py Fix not sending events over federation when using sharded event persisters (#8536) 2020-10-14 13:27:51 +01:00
python_dependencies.py Drop support for ancient prometheus_client (#8426) 2020-09-30 16:42:05 +01:00
secrets.py Stop sub-classing object (#8249) 2020-09-04 06:54:56 -04:00
server.py Move additional tasks to the background worker, part 4 (#8513) 2020-10-13 08:20:32 -04:00
types.py Use vector clocks for room stream tokens. (#8439) 2020-10-07 15:15:33 +01:00
visibility.py Do not assume that account data is of the correct form. (#8454) 2020-10-05 09:28:05 -04:00