mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fix race when persisting create event (#4404)
* Fix race when persisting create event When persisting a chunk of DAG it is sometimes requried to do a state resolution, which requires knowledge of the room version. If this happens while we're persisting the create event then we need to use that event rather than attempting to look it up in the database.
This commit is contained in:
parent
71b94eac46
commit
25dd56ace3
1
changelog.d/4404.bugfix
Normal file
1
changelog.d/4404.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix potential bug where creating or joining a room could fail
|
@ -739,6 +739,17 @@ class EventsStore(StateGroupWorkerStore, EventFederationStore, EventsWorkerStore
|
||||
}
|
||||
|
||||
events_map = {ev.event_id: ev for ev, _ in events_context}
|
||||
|
||||
# We need to get the room version, which is in the create event.
|
||||
# Normally that'd be in the database, but its also possible that we're
|
||||
# currently trying to persist it.
|
||||
room_version = None
|
||||
for ev, _ in events_context:
|
||||
if ev.type == EventTypes.Create and ev.state_key == "":
|
||||
room_version = ev.content.get("room_version", "1")
|
||||
break
|
||||
|
||||
if not room_version:
|
||||
room_version = yield self.get_room_version(room_id)
|
||||
|
||||
logger.debug("calling resolve_state_groups from preserve_events")
|
||||
|
Loading…
Reference in New Issue
Block a user