@@ -30,37 +30,72 @@ rather than skipping any that arrived late; whereas if you're looking at a
30
30
historical section of timeline (i.e. ` /messages ` ), you want to see the best
31
31
representation of the state of the room as others were seeing it at the time.
32
32
33
+ ## Outliers
33
34
34
- ## Forward extremity
35
+ We mark an event as an ` outlier ` when we haven't figured out the state for the
36
+ room at that point in the DAG yet. They are "floating" events that we haven't
37
+ yet correlated to the DAG.
35
38
36
- Most-recent-in-time events in the DAG which are not referenced by any other events' ` prev_events ` yet.
39
+ Outliers typically arise when we fetch the auth chain or state for a given
40
+ event. When that happens, we just grab the events in the state/auth chain,
41
+ without calculating the state at those events, or backfilling their
42
+ ` prev_events ` .
37
43
38
- The forward extremities of a room are used as the ` prev_events ` when the next event is sent.
44
+ So, typically, we won't have the ` prev_events ` of an ` outlier ` in the database,
45
+ (though it's entirely possible that we * might* have them for some other
46
+ reason). Other things that make outliers different from regular events:
39
47
48
+ * We don't have state for them, so there should be no entry in
49
+ ` event_to_state_groups ` for an outlier. (In practice this isn't always
50
+ the case, though I'm not sure why: see https://github.com/matrix-org/synapse/issues/12201 ).
40
51
41
- ## Backward extremity
52
+ * We don't record entries for them in the ` event_edges ` ,
53
+ ` event_forward_extremeties ` or ` event_backward_extremities ` tables.
42
54
43
- The current marker of where we have backfilled up to and will generally be the
44
- ` prev_events ` of the oldest-in-time events we have in the DAG. This gives a starting point when
45
- backfilling history.
55
+ Since outliers are not tied into the DAG, they do not normally form part of the
56
+ timeline sent down to clients via ` /sync ` or ` /messages ` ; however there is an
57
+ exception:
46
58
47
- When we persist a non-outlier event, we clear it as a backward extremity and set
48
- all of its ` prev_events ` as the new backward extremities if they aren't already
49
- persisted in the ` events ` table.
59
+ ### Out-of-band membership events
50
60
61
+ A special case of outlier events are some membership events for federated rooms
62
+ that we aren't full members of. For example:
51
63
52
- ## Outliers
64
+ * invites received over federation, before we join the room
65
+ * * rejections* for said invites
66
+ * knock events for rooms that we would like to join but have not yet joined.
53
67
54
- We mark an event as an ` outlier ` when we haven't figured out the state for the
55
- room at that point in the DAG yet.
68
+ In all the above cases, we don't have the state for the room, which is why they
69
+ are treated as outliers. They are a bit special though, in that they are
70
+ proactively sent to clients via ` /sync ` .
56
71
57
- We won't * necessarily* have the ` prev_events ` of an ` outlier ` in the database,
58
- but it's entirely possible that we * might* .
72
+ ## Forward extremity
73
+
74
+ Most-recent-in-time events in the DAG which are not referenced by any other
75
+ events' ` prev_events ` yet. (In this definition, outliers, rejected events, and
76
+ soft-failed events don't count.)
77
+
78
+ The forward extremities of a room (or at least, a subset of them, if there are
79
+ more than ten) are used as the ` prev_events ` when the next event is sent.
80
+
81
+ The "current state" of a room (ie: the state which would be used if we
82
+ generated a new event) is, therefore, the resolution of the room states
83
+ at each of the forward extremities.
84
+
85
+ ## Backward extremity
86
+
87
+ The current marker of where we have backfilled up to and will generally be the
88
+ ` prev_events ` of the oldest-in-time events we have in the DAG. This gives a starting point when
89
+ backfilling history.
59
90
60
- For example, when we fetch the event auth chain or state for a given event, we
61
- mark all of those claimed auth events as outliers because we haven't done the
62
- state calculation ourself .
91
+ Note that, unlike forward extremities, we typically don't have any backward
92
+ extremity events themselves in the database - or, if we do, they will be "outliers" (see
93
+ above). Either way, we don't expect to have the room state at a backward extremity .
63
94
95
+ When we persist a non-outlier event, if it was previously a backward extremity,
96
+ we clear it as a backward extremity and set all of its ` prev_events ` as the new
97
+ backward extremities if they aren't already persisted as non-outliers. This
98
+ therefore keeps the backward extremities up-to-date.
64
99
65
100
## State groups
66
101
0 commit comments