Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Store rejected remote invite events as outliers #4405

Merged
merged 7 commits into from
Jan 24, 2019

Conversation

erikjohnston
Copy link
Member

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.

@codecov-io
Copy link

codecov-io commented Jan 16, 2019

Codecov Report

Merging #4405 into develop will increase coverage by 1.13%.
The diff coverage is 100%.

@@             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

@erikjohnston erikjohnston requested a review from a team January 16, 2019 15:38
Copy link
Member

@richvdh richvdh left a 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?

@erikjohnston
Copy link
Member Author

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.
@erikjohnston
Copy link
Member Author

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.

Copy link
Member

@richvdh richvdh left a 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

synapse/events/__init__.py Outdated Show resolved Hide resolved
@@ -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.
Copy link
Member

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/handlers/federation.py Outdated Show resolved Hide resolved
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.
Copy link
Member

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?

@erikjohnston erikjohnston requested a review from a team January 24, 2019 18:08
Copy link
Member

@richvdh richvdh left a 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.

@erikjohnston erikjohnston merged commit 80bcca6 into develop Jan 24, 2019
@erikjohnston
Copy link
Member Author

erikjohnston commented Jan 24, 2019

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.

erikjohnston added a commit that referenced this pull request Jan 30, 2019
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.
@erikjohnston erikjohnston deleted the erikj/fixup_rejecting_invites branch March 5, 2019 13:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants