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

Remove hacky error handling for inlineDeferreds. #7950

Merged
merged 3 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7950.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify error handling in federation handler.
13 changes: 4 additions & 9 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,9 +1887,6 @@ async def _handle_new_event(
origin, event, state=state, auth_events=auth_events, backfilled=backfilled
)

# reraise does not allow inlineCallbacks to preserve the stacktrace, so we
# hack around with a try/finally instead.
success = False
try:
if (
not event.internal_metadata.is_outlier()
Expand All @@ -1903,12 +1900,10 @@ async def _handle_new_event(
await self.persist_events_and_notify(
[(event, context)], backfilled=backfilled
)
success = True
finally:
if not success:
run_in_background(
self.store.remove_push_actions_from_staging, event.event_id
)
except Exception:
run_in_background(
self.store.remove_push_actions_from_staging, event.event_id
)
clokep marked this conversation as resolved.
Show resolved Hide resolved

return context

Expand Down
18 changes: 6 additions & 12 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,6 @@ async def handle_new_client_event(

await self.action_generator.handle_push_actions_for_event(event, context)

# reraise does not allow inlineCallbacks to preserve the stacktrace, so we
# hack around with a try/finally instead.
success = False
try:
# If we're a worker we need to hit out to the master.
if not self._is_event_writer:
Expand All @@ -875,22 +872,19 @@ async def handle_new_client_event(
)
stream_id = result["stream_id"]
event.internal_metadata.stream_ordering = stream_id
success = True
return stream_id

stream_id = await self.persist_and_notify_client_event(
requester, event, context, ratelimit=ratelimit, extra_users=extra_users
)

success = True
return stream_id
finally:
if not success:
# Ensure that we actually remove the entries in the push actions
# staging area, if we calculated them.
run_in_background(
self.store.remove_push_actions_from_staging, event.event_id
)
except Exception:
# Ensure that we actually remove the entries in the push actions
# staging area, if we calculated them.
run_in_background(
self.store.remove_push_actions_from_staging, event.event_id
)

async def _validate_canonical_alias(
self, directory_handler, room_alias_str: str, expected_room_id: str
Expand Down