0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-24 22:24:15 +01:00

Don't completely die if get auth_chain or querying auth_chain requests fail

This commit is contained in:
Erik Johnston 2015-02-03 13:57:54 +00:00
parent 77a076bd25
commit 6efd4d1649

View file

@ -787,41 +787,45 @@ class FederationHandler(BaseHandler):
if missing_auth: if missing_auth:
logger.debug("Missing auth: %s", missing_auth) logger.debug("Missing auth: %s", missing_auth)
# If we don't have all the auth events, we need to get them. # If we don't have all the auth events, we need to get them.
remote_auth_chain = yield self.replication_layer.get_event_auth( try:
origin, event.room_id, event.event_id remote_auth_chain = yield self.replication_layer.get_event_auth(
) origin, event.room_id, event.event_id
)
seen_remotes = yield self.store.have_events( seen_remotes = yield self.store.have_events(
[e.event_id for e in remote_auth_chain] [e.event_id for e in remote_auth_chain]
) )
for e in remote_auth_chain: for e in remote_auth_chain:
if e.event_id in seen_remotes.keys(): if e.event_id in seen_remotes.keys():
continue continue
if e.event_id == event.event_id: if e.event_id == event.event_id:
continue continue
try: try:
auth_ids = [e_id for e_id, _ in e.auth_events] auth_ids = [e_id for e_id, _ in e.auth_events]
auth = { auth = {
(e.type, e.state_key): e for e in remote_auth_chain (e.type, e.state_key): e for e in remote_auth_chain
if e.event_id in auth_ids if e.event_id in auth_ids
} }
e.internal_metadata.outlier = True e.internal_metadata.outlier = True
logger.debug( logger.debug(
"do_auth %s missing_auth: %s", "do_auth %s missing_auth: %s",
event.event_id, e.event_id event.event_id, e.event_id
) )
yield self._handle_new_event( yield self._handle_new_event(
origin, e, auth_events=auth origin, e, auth_events=auth
) )
if e.event_id in event_auth_events: if e.event_id in event_auth_events:
auth_events[(e.type, e.state_key)] = e auth_events[(e.type, e.state_key)] = e
except AuthError: except AuthError:
pass pass
except:
# FIXME:
logger.exception("Failed to get auth chain")
# FIXME: Assumes we have and stored all the state for all the # FIXME: Assumes we have and stored all the state for all the
# prev_events # prev_events
@ -836,47 +840,52 @@ class FederationHandler(BaseHandler):
auth_ids = self.auth.compute_auth_events(event, context) auth_ids = self.auth.compute_auth_events(event, context)
local_auth_chain = yield self.store.get_auth_chain(auth_ids) local_auth_chain = yield self.store.get_auth_chain(auth_ids)
# 2. Get remote difference. try:
result = yield self.replication_layer.query_auth( # 2. Get remote difference.
origin, result = yield self.replication_layer.query_auth(
event.room_id, origin,
event.event_id, event.room_id,
local_auth_chain, event.event_id,
) local_auth_chain,
)
seen_remotes = yield self.store.have_events( seen_remotes = yield self.store.have_events(
[e.event_id for e in result["auth_chain"]] [e.event_id for e in result["auth_chain"]]
) )
# 3. Process any remote auth chain events we haven't seen. # 3. Process any remote auth chain events we haven't seen.
for ev in result["auth_chain"]: for ev in result["auth_chain"]:
if ev.event_id in seen_remotes.keys(): if ev.event_id in seen_remotes.keys():
continue continue
if ev.event_id == event.event_id: if ev.event_id == event.event_id:
continue continue
try: try:
auth_ids = [e_id for e_id, _ in ev.auth_events] auth_ids = [e_id for e_id, _ in ev.auth_events]
auth = { auth = {
(e.type, e.state_key): e for e in result["auth_chain"] (e.type, e.state_key): e for e in result["auth_chain"]
if e.event_id in auth_ids if e.event_id in auth_ids
} }
ev.internal_metadata.outlier = True ev.internal_metadata.outlier = True
logger.debug( logger.debug(
"do_auth %s different_auth: %s", "do_auth %s different_auth: %s",
event.event_id, e.event_id event.event_id, e.event_id
) )
yield self._handle_new_event( yield self._handle_new_event(
origin, ev, auth_events=auth origin, ev, auth_events=auth
) )
if ev.event_id in event_auth_events: if ev.event_id in event_auth_events:
auth_events[(ev.type, ev.state_key)] = ev auth_events[(ev.type, ev.state_key)] = ev
except AuthError: except AuthError:
pass pass
except:
# FIXME:
logger.exception("Failed to query auth chain")
# 4. Look at rejects and their proofs. # 4. Look at rejects and their proofs.
# TODO. # TODO.