Skip to content

Several places in the code use timestamp to determine event order #3325

@andybalaam

Description

@andybalaam

When are processing events, we sometimes need to know what order they are in. (For example, to decide whether an event is before the last read receipt so we know whether a room is unread.)

The correct order to use is the order in which they are provided during the sync request from the homeserver. It is the homeserver's job to determine a linear order from the DAG, and we need to agree with the homeserver to make sure we are giving the correct results for e.g. the notifications for a room.

In some places in the code we use the timestamp (ts property) of events to determine their order, because we don't have a record of the order of events from sync.

We should keep track of the server-provided event order and replace all uses of ts with the correct order. In the meantime, if we add code that depends on ts, we should reference this issue in a comment in the code.

Impact of this issue: sometimes there may be stuck unreads or notifications due to inconsistencies between how the homeserver and the client understand the order of events. This may also cause other problems - we're not certain. We think the problems we see will be relatively rare, which is why this has not yet been fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-TaskTasks for the team like planning

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions