1
0

Fix remote join predecessor race

This commit is contained in:
Erik Johnston
2020-08-20 10:25:10 +01:00
parent 98b7415fcd
commit ab73bf1c85
2 changed files with 14 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
"""Contains handlers for federation events."""
import collections
import itertools
import logging
from collections.abc import Container
@@ -1368,9 +1369,20 @@ class FederationHandler(BaseHandler):
self.config.worker.writers.events, "events", max_stream_id
)
predecessor = None
for s in state:
if s.type == EventTypes.Create:
predecessor = s.content.get("predecessor", None)
# Ensure the key is a dictionary
if not isinstance(predecessor, collections.abc.Mapping):
predecessor = None
break
# Check whether this room is the result of an upgrade of a room we already know
# about. If so, migrate over user information
predecessor = await self.store.get_room_predecessor(room_id)
# predecessor = await self.store.get_room_predecessor(room_id)
if not predecessor or not isinstance(predecessor.get("room_id"), str):
return event.event_id, max_stream_id
old_room_id = predecessor["room_id"]

View File

@@ -675,7 +675,7 @@ class EventCreationHandler(object):
event.event_id,
prev_event.event_id,
)
return await self.store.get_stream_token_for_event(prev_event.event_id)
return await self.store.get_stream_id_for_event(prev_event.event_id)
return await self.handle_new_client_event(
requester=requester, event=event, context=context, ratelimit=ratelimit