From 4c229ea36cd8553521064a294fe5d493487df910 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 13 Jan 2023 17:45:44 +0000 Subject: [PATCH 1/4] Stabilise serving partial join responses Serving partial join responses is no longer experiemntal; the undocumented config flag `experimental.msc3706_enabled` has been removed. Synapse continues to _request_ a partial join only if the undocumented config flag `experimental.faster_joins` is set to `true`; this setting remains present and unaffected. --- synapse/config/experimental.py | 5 +---- .../federation/transport/server/federation.py | 21 ++++++++----------- tests/federation/test_federation_server.py | 3 +-- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index a8b2db372d56..685c2100452c 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -73,12 +73,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: "msc3202_transaction_extensions", False ) - # MSC3706 (server-side support for partial state in /send_join responses) - self.msc3706_enabled: bool = experimental.get("msc3706_enabled", False) - # experimental support for faster joins over federation # (MSC2775, MSC3706, MSC3895) - # requires a target server with msc3706_enabled enabled. + # requires a target server that can provide a partial join response (MSC3706) self.faster_joins_enabled: bool = experimental.get("faster_joins", False) # MSC3720 (Account status endpoint) diff --git a/synapse/federation/transport/server/federation.py b/synapse/federation/transport/server/federation.py index c0a700905b8b..88d1045181b9 100644 --- a/synapse/federation/transport/server/federation.py +++ b/synapse/federation/transport/server/federation.py @@ -422,7 +422,6 @@ def __init__( server_name: str, ): super().__init__(hs, authenticator, ratelimiter, server_name) - self._msc3706_enabled = hs.config.experimental.msc3706_enabled async def on_PUT( self, @@ -435,17 +434,15 @@ async def on_PUT( # TODO(paul): assert that event_id parsed from path actually # match those given in content - partial_state = False - if self._msc3706_enabled: - # The stable query parameter wins, if it disagrees with the unstable - # parameter for some reason. - stable_param = parse_boolean_from_args(query, "omit_members", default=None) - if stable_param is not None: - partial_state = stable_param - else: - partial_state = parse_boolean_from_args( - query, "org.matrix.msc3706.partial_state", default=False - ) + # The stable query parameter wins, if it disagrees with the unstable + # parameter for some reason. + stable_param = parse_boolean_from_args(query, "omit_members", default=None) + if stable_param is not None: + partial_state = stable_param + else: + partial_state = parse_boolean_from_args( + query, "org.matrix.msc3706.partial_state", default=False + ) result = await self.handler.on_send_join_request( origin, content, room_id, caller_supports_partial_state=partial_state diff --git a/tests/federation/test_federation_server.py b/tests/federation/test_federation_server.py index 27770304be43..be719e49c0ca 100644 --- a/tests/federation/test_federation_server.py +++ b/tests/federation/test_federation_server.py @@ -211,9 +211,8 @@ def test_send_join(self): ) self.assertEqual(r[("m.room.member", joining_user)].membership, "join") - @override_config({"experimental_features": {"msc3706_enabled": True}}) def test_send_join_partial_state(self) -> None: - """When MSC3706 support is enabled, /send_join should return partial state""" + """/send_join should return partial state, if requested""" joining_user = "@misspiggy:" + self.OTHER_SERVER_NAME join_result = self._make_join(joining_user) From 497e8a88463b7e03ec07f5fa2a24431a1fa95aef Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 13 Jan 2023 18:10:07 +0000 Subject: [PATCH 2/4] Changelog --- changelog.d/14839.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14839.feature diff --git a/changelog.d/14839.feature b/changelog.d/14839.feature new file mode 100644 index 000000000000..7ca68bd34011 --- /dev/null +++ b/changelog.d/14839.feature @@ -0,0 +1 @@ +Faster joins: always serve a partial join response to servers that request it. From 3fd68585fbee8a422df95ad81154e77e4a851115 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 13 Jan 2023 18:37:41 +0000 Subject: [PATCH 3/4] Stop setting the config option --- docker/complement/conf/workers-shared-extra.yaml.j2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/complement/conf/workers-shared-extra.yaml.j2 b/docker/complement/conf/workers-shared-extra.yaml.j2 index cb839fed078d..746083b24bd7 100644 --- a/docker/complement/conf/workers-shared-extra.yaml.j2 +++ b/docker/complement/conf/workers-shared-extra.yaml.j2 @@ -94,8 +94,6 @@ allow_device_name_lookup_over_federation: true experimental_features: # Enable history backfilling support msc2716_enabled: true - # server-side support for partial state in /send_join responses - msc3706_enabled: true {% if not workers_in_use %} # client-side support for partial state in /send_join responses faster_joins: true From d4a4cd31d70ddab2b90b5ac639335e4ba2b01ce6 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 16 Jan 2023 11:59:51 +0000 Subject: [PATCH 4/4] Reinstate config option for reading old query parm --- changelog.d/14839.feature | 2 +- synapse/config/experimental.py | 7 +++++++ synapse/federation/transport/server/federation.py | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/changelog.d/14839.feature b/changelog.d/14839.feature index 7ca68bd34011..a4206be007dd 100644 --- a/changelog.d/14839.feature +++ b/changelog.d/14839.feature @@ -1 +1 @@ -Faster joins: always serve a partial join response to servers that request it. +Faster joins: always serve a partial join response to servers that request it with the stable query param. diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 685c2100452c..27c539d048b4 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -73,6 +73,13 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: "msc3202_transaction_extensions", False ) + # MSC3706 (server-side support for partial state in /send_join responses) + # Synapse will always serve partial state responses to requests using the stable + # query parameter `omit_members`. If this flag is set, Synapse will also serve + # partial state responses to requests using the unstable query parameter + # `org.matrix.msc3706.partial_state`. + self.msc3706_enabled: bool = experimental.get("msc3706_enabled", False) + # experimental support for faster joins over federation # (MSC2775, MSC3706, MSC3895) # requires a target server that can provide a partial join response (MSC3706) diff --git a/synapse/federation/transport/server/federation.py b/synapse/federation/transport/server/federation.py index 88d1045181b9..17c427387e03 100644 --- a/synapse/federation/transport/server/federation.py +++ b/synapse/federation/transport/server/federation.py @@ -422,6 +422,7 @@ def __init__( server_name: str, ): super().__init__(hs, authenticator, ratelimiter, server_name) + self._read_msc3706_query_param = hs.config.experimental.msc3706_enabled async def on_PUT( self, @@ -434,12 +435,13 @@ async def on_PUT( # TODO(paul): assert that event_id parsed from path actually # match those given in content + partial_state = False # The stable query parameter wins, if it disagrees with the unstable # parameter for some reason. stable_param = parse_boolean_from_args(query, "omit_members", default=None) if stable_param is not None: partial_state = stable_param - else: + elif self._read_msc3706_query_param: partial_state = parse_boolean_from_args( query, "org.matrix.msc3706.partial_state", default=False )