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

Use READ COMMITTED isolation level when purging rooms #12942

Merged
merged 12 commits into from
Jul 18, 2022
1 change: 1 addition & 0 deletions changelog.d/12942.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use lower isolation level when purging rooms to avoid serialization errors. Contributed by Nick @ Beeper.
6 changes: 5 additions & 1 deletion synapse/storage/databases/main/purge_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from synapse.storage.database import LoggingTransaction
from synapse.storage.databases.main import CacheInvalidationWorkerStore
from synapse.storage.databases.main.state import StateGroupWorkerStore
from synapse.storage.engines._base import IsolationLevel
from synapse.types import RoomStreamToken

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -318,7 +319,10 @@ async def purge_room(self, room_id: str) -> List[int]:
The list of state groups to delete.
"""
return await self.db_pool.runInteraction(
"purge_room", self._purge_room_txn, room_id
"purge_room",
self._purge_room_txn,
room_id=room_id,
isolation_level=IsolationLevel.READ_COMMITTED,
Fizzadar marked this conversation as resolved.
Show resolved Hide resolved
)

def _purge_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[int]:
Fizzadar marked this conversation as resolved.
Show resolved Hide resolved
Expand Down