Skip to content

example 1 for gedisa missing messages#51

Closed
jason-famedly wants to merge 1 commit intomasterfrom
jason/gedisa-exp
Closed

example 1 for gedisa missing messages#51
jason-famedly wants to merge 1 commit intomasterfrom
jason/gedisa-exp

Conversation

@jason-famedly
Copy link
Copy Markdown
Member

@jason-famedly jason-famedly commented Jul 1, 2025

One of two potential options. Unfinished:

  • need to adjust the get_missing_events response to be smarter
  • decide if keeping the Linearizer I included

This will send additional forward extremities that are in existence during a remote room join to the remote server requesting the join but not to other servers that may already be in the room.

The order of events:

  1. Simultaneous:
    A. make_join from remote server
    B. a message sent from local server
    C. make_join response from local server that does not include the message as a prev_event
  2. send_join from remote server, response from local server
    A. partial state join begins
  3. remote server receives the message as a forward extremity via it's /send endpoint, saves it in a queue until the partial state join begins syncing additional room state
  4. remote server begins syncing additional room state, sees the item in the queue and begins processing that.
    A. remote server places a backfill request(which starts at the invite event, because of how backfill points are calculated)
    B. remote server places a /get_missing_events request, trying to retrieve events between the join event and the message event(spoiler: there are none).
    1. request is made with latest_events being the message event and earliest_events being the join, because that is how the stream orderings look on the remote server. The SQL for answering a get_missing_events request just does a walk through event_edges based on prev_events, and returns up to the limit requested. The added wrinkle that the spec says that /get_missing_events is only supposed to return prev_events related to(in this case) the message event means that making /get_missing_events smarter is rather difficult(have to work around Kahn's Algorithm).

The backfill and the get_missing_events are technically a race, in that both are essentially retrieving the same data twice. The default limit placed for /get_missing_events is 10. So it may be likely that this is not a large problem, although it is technically doubling the work. Since they are both making events de-outliered, neither can see that they are doing double duty. So:

I applied a Linearizer to try and mitigate this, I don't recall if it worked or not.

@jason-famedly
Copy link
Copy Markdown
Member Author

Closing in favor of #71

FrenchGithubUser added a commit that referenced this pull request Nov 26, 2025
…during the remote join handshake (#71)

### TLDR
Use a "dummy" event to tie together forward extremities, and proactively
send it to all servers in the room. This allows recently joined servers
to become aware of recent events that would otherwise have "slipped
through the cracks" and thus not be retrievable.

NOTE: While this does send the "dummy" event to all servers in the room,
regardless of if they should care or not, at some point a new event will
reference this dummy event and require it's retrieval. Since it was
proactively sent, this will now not be necessary. This assists in
preventing forks in the DAG

### Alternatives
Unlike #51 which 'pushes' the missing event directly, this causes the
event to be 'pulled' by referencing it as a `prev_event` of a dummy
event. Since the 'dummy event' does not get passed into the client, it
is effectively invisible.

Draw-backs of #51 meant it was not always certain if the 'pushed event'
would show up in `/sync` or in `/messages`, but usually was in `/sync`.
This method always has the 'missing event' show up in `/messages`, which
I feel is more technically correct as that event was(albeit just barely)
created before the 'join event' is persisted.

### The Process
The order of events:
1. `make_join` from remote server, response sent
2. Message A sent from local server
3. `send_join` from remote server, response from local server. Message A
is not in this(as it is not state and is not referenced in any events
that are included). Join event is persisted on local server.
4. Local server realizes there are two forward extremities just after
persisting the join event.
A. Creates a `org.matrix.dummy_event` that has `prev_events` containing
both the join and message A.
   B. Sends this dummy event to all servers in the room. 
5. Remote server receives the dummy event via it's `/send` endpoint,
saves it in a queue until the partial state join begins syncing
additional room state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant