From 58317e6bb31fd6f26fdd63d12cebae445ba52e3c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 20 Jul 2022 16:01:19 -0500 Subject: [PATCH 1/5] Fix `get_pdu` asking every destination even after it finds an event As discovered by @richvdh, https://github.com/matrix-org/synapse/pull/13320#discussion_r924273830 --- synapse/federation/federation_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 842f5327c227..02276ed9951d 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -403,9 +403,9 @@ async def get_pdu( # Prime the cache self._get_pdu_cache[event.event_id] = event - # FIXME: We should add a `break` here to avoid calling every - # destination after we already found a PDU (will follow-up - # in a separate PR) + # Now that we have an event, we can break out of this + # loop and stop asking other destinations. + break except SynapseError as e: logger.info( From 0929b16112a13158de050e93ef594d6a9f39a1c0 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 20 Jul 2022 16:03:34 -0500 Subject: [PATCH 2/5] Add changelog --- changelog.d/13346.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13346.misc diff --git a/changelog.d/13346.misc b/changelog.d/13346.misc new file mode 100644 index 000000000000..c8fea33d3de9 --- /dev/null +++ b/changelog.d/13346.misc @@ -0,0 +1 @@ +Fix `get_pdu` asking every remote destination even after it finds an event. From 0881f2a5c9867f4ebd3f4b9f5f3b7269162dc4a4 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 25 Jul 2022 11:12:30 -0500 Subject: [PATCH 3/5] Describe as long-standing bug Co-authored-by: Erik Johnston --- changelog.d/13346.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13346.misc b/changelog.d/13346.misc index c8fea33d3de9..8893214f327d 100644 --- a/changelog.d/13346.misc +++ b/changelog.d/13346.misc @@ -1 +1 @@ -Fix `get_pdu` asking every remote destination even after it finds an event. +Fix long-standing bug where Synapse sometimes asked many different remote hosts for the same event. From 1b0cf9eb6954ff940d6f110721653c069442bb1d Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 25 Jul 2022 11:27:52 -0500 Subject: [PATCH 4/5] Update changelog.d/13346.misc --- changelog.d/13346.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13346.misc b/changelog.d/13346.misc index 8893214f327d..e130beaa621f 100644 --- a/changelog.d/13346.misc +++ b/changelog.d/13346.misc @@ -1 +1 @@ -Fix long-standing bug where Synapse sometimes asked many different remote hosts for the same event. +Fix long-standing bug in `get_pdu` asking every remote destination even after it finds an event. From 97c046984f0d5ea1ef7d096c5eb8da6d283a8046 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 26 Jul 2022 12:10:05 -0500 Subject: [PATCH 5/5] Explain that the bug was never hit --- changelog.d/13346.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13346.misc b/changelog.d/13346.misc index e130beaa621f..06557c8481eb 100644 --- a/changelog.d/13346.misc +++ b/changelog.d/13346.misc @@ -1 +1 @@ -Fix long-standing bug in `get_pdu` asking every remote destination even after it finds an event. +Fix long-standing bugged logic which was never hit in `get_pdu` asking every remote destination even after it finds an event.