Skip to content

Consider changing /messages to use stream ordering for eventsΒ #852

@timokoesters

Description

@timokoesters

Today the /messages endpoint documentation does not say anything about the
ordering of the events. /sync hints at one possible ordering method:

Events are ordered in this API according to the arrival time of the event on
the homeserver. This can conflict with other APIs which order events based on
their partial ordering in the event graph.

The current concept of ordering based on event graph is not ideal for the following reasons:

  1. It's not clearly documented
  • Which event is picked when an event has multiple prev events?
  • What happens if a prev event is not known to the server
  • What happens if an event has no prev events, or builds a circle of prev events
    or is it's own prev event. This is not checked in the federation api.
  1. You can't notify the client about updates
  • Clients might cache events from /messages, but this list of events could be
    incomplete because we don't know about events of a fork
  • /sync can't be used to send these updates because it's response will be limited
    if there are too many events

Possible solution:

/messages uses the same order as /sync, which is the order at which events
arrive at the server, not sorted at all.

This has the advantage of being a lot simpler and therefore doesn't have many
edge cases.

A problem is that Matrix events often arrive in batches from other servers, so
conversations might become unreadable because you first see all messages from
one user and then all messages from the other user.

This can be improved by adding more logic in the client (for example sort the
events by timestamp) and by improving the /messages api (maybe it can send prev
events to the client to improve ordering or call /context on them).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureSuggestion for a significant extension which needs considerable consideration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions