Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Ignore incoming events for rooms that we have left #2490

Merged
merged 5 commits into from Oct 10, 2017

Conversation

erikjohnston
Copy link
Member

When synapse receives an event for a room its not in over federation, it
double checks with the remote server to see if it is in fact in the
room. This is done so that if the server has forgotten about the room
(usually as a result of the database being dropped) it can recover from
it.

However, in the presence of state resets in large rooms, this can cause
a lot of work for servers that have legitimately left. As a hacky
solution that supports both cases we drop incoming events for rooms that
we have explicitly left.

This means that we no longer support the case of servers having
forgotten that they've rejoined a room, but that is sufficiently rare
that we're not going to support it for now.

When synapse receives an event for a room its not in over federation, it
double checks with the remote server to see if it is in fact in the
room. This is done so that if the server has forgotten about the room
(usually as a result of the database being dropped) it can recover from
it.

However, in the presence of state resets in large rooms, this can cause
a lot of work for servers that have legitimately left. As a hacky
solution that supports both cases we drop incoming events for rooms that
we have explicitly left.

This means that we no longer support the case of servers having
forgotten that they've rejoined a room, but that is sufficiently rare
that we're not going to support it for now.
raise Exception("Invalid host name")

defer.returnValue(True)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is almost an exact copy of is_host_joined above.

if not is_in_room:
was_in_room = yield self.store.was_host_joined(
pdu.room_id, self.server_name,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spurious LF?

@ara4n
Copy link
Member

ara4n commented Oct 3, 2017

lgtm. my gut is that the auto-rejoin-rooms stuff is too magical and complicated to preserve long-term, but given it can be done easily here... why not.

@erikjohnston
Copy link
Member Author

lgtm. my gut is that the auto-rejoin-rooms stuff is too magical and complicated to preserve long-term, but given it can be done easily here... why not.

Its worth noting that the actual number of lines to support this is relatively small by the looks of things, as it reuses existing code paths.

@@ -125,6 +125,28 @@ def on_receive_pdu(self, origin, pdu, get_missing=True):
self.room_queues[pdu.room_id].append((pdu, origin))
return

# If we're no longer in the room just ditch the event entirely. This
# is probably an old server that has come back and thinks we're still
# in the room.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or we've been rejoined to the room by a state reset.

@@ -533,6 +533,38 @@ def is_host_joined(self, room_id, host):

defer.returnValue(True)

@cachedInlineCallbacks()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm; do we not need to arrange for this cache to be flushed?

@cachedInlineCallbacks()
def was_host_joined(self, room_id, host):
"""Check whether the server is or ever was in the room.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document the arg types and return types please

@richvdh richvdh assigned erikjohnston and unassigned richvdh Oct 3, 2017
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Oct 3, 2017
host (str)

Returns:
bool: whether the host is/was in the room or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nuh. it returns a deferred.

also: "True if the host is/was in the room. Otherwise False".

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.

lgtm other than comment nitpickery

@richvdh richvdh assigned erikjohnston and unassigned richvdh Oct 5, 2017
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.

None yet

3 participants