diff options
author | Erik Johnston <erik@matrix.org> | 2020-10-13 12:07:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 12:07:56 +0100 |
commit | b2486f6656bec2307e62de19d2830994a42b879d (patch) | |
tree | 630ab6e5b341a53b5f6c1f7e966ab79673eb73b9 /synapse/handlers/federation.py | |
parent | Merge branch 'master' into develop (diff) | |
download | synapse-b2486f6656bec2307e62de19d2830994a42b879d.tar.xz |
Fix message duplication if something goes wrong after persisting the event (#8476)
Should fix #3365.
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r-- | synapse/handlers/federation.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 5ac2fc5656..455acd7669 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -2966,17 +2966,20 @@ class FederationHandler(BaseHandler): return result["max_stream_id"] else: assert self.storage.persistence - max_stream_token = await self.storage.persistence.persist_events( + + # Note that this returns the events that were persisted, which may not be + # the same as were passed in if some were deduplicated due to transaction IDs. + events, max_stream_token = await self.storage.persistence.persist_events( event_and_contexts, backfilled=backfilled ) if self._ephemeral_messages_enabled: - for (event, context) in event_and_contexts: + for event in events: # If there's an expiry timestamp on the event, schedule its expiry. self._message_handler.maybe_schedule_expiry(event) if not backfilled: # Never notify for backfilled events - for event, _ in event_and_contexts: + for event in events: await self._notify_persisted_event(event, max_stream_token) return max_stream_token.stream |