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

Faster joins: room alias server list may be incomplete #13287

Closed
Tracked by #14030
richvdh opened this issue Jul 15, 2022 · 5 comments · Fixed by #14292
Closed
Tracked by #14030

Faster joins: room alias server list may be incomplete #13287

richvdh opened this issue Jul 15, 2022 · 5 comments · Fixed by #14292
Assignees
Labels
A-Federated-Join joins over federation generally suck T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@richvdh
Copy link
Member

richvdh commented Jul 15, 2022

If a room alias is added on a server that is doing a faster join, the list of servers associated with the alias may be incomplete until the faster join completes.

@richvdh richvdh added this to the Faster joins (further work) milestone Jul 15, 2022
@squahtx squahtx added A-Federated-Join joins over federation generally suck T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Jul 15, 2022
@richvdh
Copy link
Member Author

richvdh commented Oct 4, 2022

Currently we probably return just ourselves, which is useless. We should probably return the list of servers we got from the /send_join, which will be good enough.

@richvdh
Copy link
Member Author

richvdh commented Oct 4, 2022

(This is a bit of an edge-case as it's unlikely someone will add an alias (and then someone else will join through it) during a faster join)

@DMRobertson
Copy link
Contributor

DMRobertson commented Oct 25, 2022

The current situation is that we block waiting for full state:

  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/rest/client/directory.py", line 91, in on_PUT
  synapse_main |     await self.directory_handler.create_association(
  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/handlers/directory.py", line 175, in create_association
  synapse_main |     await self._create_association(room_alias, room_id, servers, creator=user_id)
  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/handlers/directory.py", line 88, in _create_association
  synapse_main |     servers = await self._storage_controllers.state.get_current_hosts_in_room(
  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/storage/controllers/state.py", line 539, in get_current_hosts_in_room
  synapse_main |     await self._partial_state_room_tracker.await_full_state(room_id)
  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/logging/opentracing.py", line 889, in _wrapper
  synapse_main |     return await func(*args, **kwargs)  # type: ignore[misc]
  synapse_main |   File "/usr/local/lib/python3.9/site-packages/synapse/storage/util/partial_state_events_tracker.py", line 172, in await_full_state
  synapse_main |     logger.info(

So we need to change that behaviour.

Also: do we persist the list of servers we get from a send_join response? Presumably this is what partial_state_rooms_servers is for?

Edit: ahh yes, get_partial_state_servers_at_join:

@cached(iterable=True)
async def get_partial_state_servers_at_join(self, room_id: str) -> Sequence[str]:
"""Gets the list of servers in a partial state room at the time we joined it.
Returns:
The `servers_in_room` list from the `/send_join` response for partial state
rooms. May not be accurate or complete, as it comes from a remote
homeserver.
An empty list for full state rooms.
"""
return await self.db_pool.simple_select_onecol(
"partial_state_rooms_servers",
keyvalues={"room_id": room_id},
retcol="server_name",
desc="get_partial_state_servers_at_join",
)

@DMRobertson
Copy link
Contributor

Presumably once we have completed the resync we need to update the alias tables to reflect the full list of servers we now know about?

@DMRobertson
Copy link
Contributor

Presumably once we have completed the resync we need to update the alias tables to reflect the full list of servers we now know about?

On reflection, I don't think this is correct. Quoting MSC3706:

servers_in_room: A new field of type [string], listing the servers active in the room (ie, those with joined members) before the join.

We are trusting the resident server to accurately provide that list of servers in the roomand the state at our join event. The resync gives us the state at that join event, so there shouldn't suddenly be a different set of servers in the room to deal with... if the resident server is well-behaved. (Do we want to check that?)

What I think this means is: we have to react to new servers joining the room after a partial join in exactly the same way as after a full join?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Federated-Join joins over federation generally suck T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants