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

Make outgoing device list tracking work after we partial-join #13891

Description

@DMRobertson

To fix "/keys/query requests on a remote homeserver must not return stale data.":

  • Store the current device list stream ID when we start a partial join
  • When we transition from partial to fully joined, send all device list updates in device_list_changes_in_room since we last joined the room (by referring to the recorded stream ID) for the room to all servers that are either:
    1. are in the room; or
    2. have had a membership change between the state at the initial join and the new current state.

Originally posted by @erikjohnston in #12993 (comment)

Activity

  1. squahtx commented on Sep 23, 2022

    @squahtx
    Contributor

    There are complement tests for this on the squah/faster_room_joins_device_list_tracking branch (see the TestPartialStateJoin/Outgoing_device_list_updates/* tests)

  2. DMRobertson commented on Sep 23, 2022

    @DMRobertson
    ContributorAuthor

    To do this:

    • New migration that adds another column to the "paritally joined rooms" table

    • In/near store_partial_state_room write the device list stream ID to that column

    • maybe also store the join event ID we get back from the send_join response?

    • When we transition ->
      https://github.com/matrix-org/synapse/blob/e3512a7719e90f49e1056e1480358e9ff9de1d9d/synapse/storage /controllers/persist_events.py#L481:L481

      1. work out which servers to send to. For a): standard function get current hosts or similar. For b) get state at the join event ID (which should now exist) and compare to the current state. Want some kind of symmetric diference of dicts.
      2. work out what to send them. Should be a simple select from device_list_changes_in_room with a fixed room_id and where stream_id > ?.

    Send out device list updates: add_device_list_outbound_pokes

  3. added
    T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
    on Sep 23, 2022
  4. squahtx commented on Sep 23, 2022

    @squahtx
    Contributor

    I should mention that while we have partial state, we always send out device list updates to the servers listed in the servers_in_room /send_join response: #13874
    so there may be opportunity for optimization based on that

  5. erikjohnston commented on Sep 28, 2022

    @erikjohnston
    Member

    There are complement tests for this on the squah/faster_room_joins_device_list_tracking branch (see the TestPartialStateJoin/Outgoing_device_list_updates/* tests)

    I get:

    === RUN   TestPartialStateJoin/Outgoing_device_list_updates/Device_list_updates_reach_incorrectly_absent_servers_once_partial_state_join_completes_even_though_remote_server_left_room
        client.go:604: [CSAPI] POST hs1/_matrix/client/v3/register => 400 Bad Request (11.298801ms)
        federation_room_join_partial_state_test.go:1508: CSAPI.MustDo POST http://localhost:49249/_matrix/client/v3/register returned HTTP 400 : {"errcode":"M_USER_IN_USE","error":"User ID already taken."}
    

    failure on that branch

  6. self-assigned this
    on Sep 28, 2022
  7. squahtx commented on Sep 28, 2022

    @squahtx
    Contributor
    === RUN   TestPartialStateJoin/Outgoing_device_list_updates/Device_list_updates_reach_incorrectly_absent_servers_once_partial_state_join_completes_even_though_remote_server_left_room
        client.go:604: [CSAPI] POST hs1/_matrix/client/v3/register => 400 Bad Request (11.298801ms)
        federation_room_join_partial_state_test.go:1508: CSAPI.MustDo POST http://localhost:49249/_matrix/client/v3/register returned HTTP 400 : {"errcode":"M_USER_IN_USE","error":"User ID already taken."}
    

    failure on that branch

    My mistake, that branch is ever so slightly out of date. squah/faster_room_joins_device_list_tracking_outgoing_2 is the right one to use and all its tests are passing with #13934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-Device-List-TrackingTelling clients about other devices. Often related to E2EE.A-Federated-Joinjoins over federation generally suckT-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions