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

Commit 9372f6f

Browse files
authored
Fix logging context misuse when we fail to persist a federation event (#13089)
When we fail to persist a federation event, we kick off a task to remove its push actions in the background, using the current logging context. Since we don't `await` that task, we may finish our logging context before the task finishes. There's no reason to not `await` the task, so let's do that. Signed-off-by: Sean Quah <[email protected]>
1 parent 8ceed5e commit 9372f6f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

changelog.d/13089.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where a finished logging context would be re-started when Synapse failed to persist an event from federation.

synapse/handlers/federation_event.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from synapse.events import EventBase
5858
from synapse.events.snapshot import EventContext
5959
from synapse.federation.federation_client import InvalidResponseError
60-
from synapse.logging.context import nested_logging_context, run_in_background
60+
from synapse.logging.context import nested_logging_context
6161
from synapse.metrics.background_process_metrics import run_as_background_process
6262
from synapse.replication.http.devices import ReplicationUserDevicesResyncRestServlet
6363
from synapse.replication.http.federation import (
@@ -1964,9 +1964,7 @@ async def _run_push_actions_and_persist_event(
19641964
event.room_id, [(event, context)], backfilled=backfilled
19651965
)
19661966
except Exception:
1967-
run_in_background(
1968-
self._store.remove_push_actions_from_staging, event.event_id
1969-
)
1967+
await self._store.remove_push_actions_from_staging(event.event_id)
19701968
raise
19711969

19721970
async def persist_events_and_notify(

0 commit comments

Comments
 (0)