Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Ignore incoming events for rooms that we have left #2490
Conversation
| + raise Exception("Invalid host name") | ||
| + | ||
| + defer.returnValue(True) | ||
| + |
erikjohnston
assigned
richvdh
Oct 3, 2017
| + if not is_in_room: | ||
| + was_in_room = yield self.store.was_host_joined( | ||
| + pdu.room_id, self.server_name, | ||
| + |
|
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. |
ara4n
referenced this pull request
Oct 3, 2017
Closed
ignore rogue events from rooms we have left #2489
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. |
| @@ -533,6 +533,38 @@ def is_host_joined(self, room_id, host): | ||
| defer.returnValue(True) | ||
| + @cachedInlineCallbacks() |
| + @cachedInlineCallbacks() | ||
| + def was_host_joined(self, room_id, host): | ||
| + """Check whether the server is or ever was in the room. | ||
| + """ |
richvdh
assigned
erikjohnston
and unassigned
richvdh
Oct 3, 2017
erikjohnston
added some commits
Oct 3, 2017
erikjohnston
assigned
richvdh
and unassigned
erikjohnston
Oct 3, 2017
| + host (str) | ||
| + | ||
| + Returns: | ||
| + bool: whether the host is/was in the room or not |
richvdh
Oct 5, 2017
Member
nuh. it returns a deferred.
also: "True if the host is/was in the room. Otherwise False".
erikjohnston commentedOct 3, 2017
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.