Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 04ca3a5

Browse files
authored
Use READ COMMITTED isolation level when inserting read receipts (#12957)
1 parent dd2d66b commit 04ca3a5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog.d/12957.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use lower isolation level when inserting read receipts to avoid serialization errors. Contributed by Nick @ Beeper.

synapse/storage/databases/main/receipts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
LoggingTransaction,
3737
)
3838
from synapse.storage.engines import PostgresEngine
39+
from synapse.storage.engines._base import IsolationLevel
3940
from synapse.storage.util.id_generators import (
4041
AbstractStreamIdTracker,
4142
MultiWriterIdGenerator,
@@ -764,6 +765,10 @@ async def insert_receipt(
764765
linearized_event_id,
765766
data,
766767
stream_id=stream_id,
768+
# Read committed is actually beneficial here because we check for a receipt with
769+
# greater stream order, and checking the very latest data at select time is better
770+
# than the data at transaction start time.
771+
isolation_level=IsolationLevel.READ_COMMITTED,
767772
)
768773

769774
# If the receipt was older than the currently persisted one, nothing to do.

0 commit comments

Comments
 (0)