diff options
author | Nick Mills-Barrett <nick@beeper.com> | 2022-06-09 09:44:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 09:44:16 +0100 |
commit | 04ca3a52f68275ce85355fb4c56f656080b20c92 (patch) | |
tree | fadb299fbaf849150fbed4dbca66e0d31b42c97b | |
parent | Move the (unstable) `dir` parameter for /relations behind an experimental fla... (diff) | |
download | synapse-04ca3a52f68275ce85355fb4c56f656080b20c92.tar.xz |
Use READ COMMITTED isolation level when inserting read receipts (#12957)
-rw-r--r-- | changelog.d/12957.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/receipts.py | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/changelog.d/12957.misc b/changelog.d/12957.misc new file mode 100644 index 0000000000..0c075276ec --- /dev/null +++ b/changelog.d/12957.misc @@ -0,0 +1 @@ +Use lower isolation level when inserting read receipts to avoid serialization errors. Contributed by Nick @ Beeper. diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py index 21e954ccc1..b6106affa6 100644 --- a/synapse/storage/databases/main/receipts.py +++ b/synapse/storage/databases/main/receipts.py @@ -36,6 +36,7 @@ from synapse.storage.database import ( LoggingTransaction, ) from synapse.storage.engines import PostgresEngine +from synapse.storage.engines._base import IsolationLevel from synapse.storage.util.id_generators import ( AbstractStreamIdTracker, MultiWriterIdGenerator, @@ -764,6 +765,10 @@ class ReceiptsWorkerStore(SQLBaseStore): linearized_event_id, data, stream_id=stream_id, + # Read committed is actually beneficial here because we check for a receipt with + # greater stream order, and checking the very latest data at select time is better + # than the data at transaction start time. + isolation_level=IsolationLevel.READ_COMMITTED, ) # If the receipt was older than the currently persisted one, nothing to do. |