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

Commit

Permalink
Use READ COMMITTED isolation level when inserting read receipts (#12957)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar authored Jun 9, 2022
1 parent dd2d66b commit 04ca3a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/12957.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use lower isolation level when inserting read receipts to avoid serialization errors. Contributed by Nick @ Beeper.
5 changes: 5 additions & 0 deletions synapse/storage/databases/main/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
LoggingTransaction,
)
from synapse.storage.engines import PostgresEngine
from synapse.storage.engines._base import IsolationLevel
from synapse.storage.util.id_generators import (
AbstractStreamIdTracker,
MultiWriterIdGenerator,
Expand Down Expand Up @@ -764,6 +765,10 @@ async def insert_receipt(
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.
Expand Down

0 comments on commit 04ca3a5

Please sign in to comment.