-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Store rejected remote invite events as outliers #4405
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4405 +/- ##
===========================================
+ Coverage 73.64% 74.78% +1.13%
===========================================
Files 302 336 +34
Lines 29818 33998 +4180
Branches 4895 5528 +633
===========================================
+ Hits 21960 25425 +3465
- Misses 6426 7007 +581
- Partials 1432 1566 +134 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might all be valid, but I'm struggling to see what it has to do with how we store rejections. Could you clarify?
Oh, the terminology here isn't great. These aren't rejected invite events, but leave events where the user has declined the invite to a room |
Currently they're stored as non-outliers even though the server isn't in the room, which can be problematic in places where the code assumes it has the state for all non outlier events. In particular, there is an edge case where persisting the leave event triggers a state resolution, which requires looking up the room version from state. Since the server doesn't have the state, this causes an exception to be thrown.
5408728
to
03ced6c
Compare
03ced6c
to
7c288c2
Compare
I've now tidied things up a bit, including moving the signing to where we actually create the event, rather than doing a weird resigning long after the fact. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appear to be two completely orthogonal changes here (moving the signing, and setting the new_remote_event
flag), but otherwise it looks plausible modulo the below
@@ -571,7 +573,18 @@ def send_request(destination): | |||
if "prev_state" not in pdu_dict: | |||
pdu_dict["prev_state"] = [] | |||
|
|||
ev = builder.EventBuilder(pdu_dict) | |||
# Strip off the fields that we want to clobber. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add something to the docstring to say that we will do the hashing/signing magic?
synapse/events/__init__.py
Outdated
def is_new_remote_event(self): | ||
"""Whether this is a new remote event, like an invite or an invite | ||
rejection. This is needed as those events are marked as outliers, but | ||
they still need to be processed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you define "processed" a bit better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we could have come up with a less unwieldy term than "out of band membership", but meh, naming is hard. lgtm.
Part of me feels like the entire thing with remote invites is a bodge job, which is why its hard to name sensibly. |
This was broken in PR #4405, commit 886e5ac, where we changed remote rejections to be outliers. The fix is to explicitly add the leave event in when we know its an out of band invite. We can't always add the event as if the server is/was in the room there might be more events to send down the sync than just the leave.
Currently they're stored as non-outliers even though the server isn't in the room, which can be problematic in places where the code assumes it has the state for all non outlier events.
In particular, there is an edge case where persisting the leave event triggers a state resolution, which requires looking up the room version from state. Since the server doesn't have the state, this causes an exception to be thrown.