-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use event streams to calculate presence #4942
Conversation
0a63923
to
b02b719
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4942 +/- ##
===========================================
+ Coverage 60.44% 60.52% +0.07%
===========================================
Files 331 328 -3
Lines 34100 34173 +73
Branches 5627 5647 +20
===========================================
+ Hits 20612 20683 +71
+ Misses 12017 12011 -6
- Partials 1471 1479 +8 |
I'm still figuring out quite how to test this fixes the bug, but at least we have sytests to check that the correct behaviour happens |
Primarily this fixes a bug in the handling of remote users joining a room where the server sent out the presence for all local users in the room to all servers in the room. We also change to using the state delta stream, rather than the distributor, as it will make it easier to split processing out of the master process (as well as being more flexible). Finally, when sending presence states to newly joined servers we filter out old presence states to reduce the number sent. Initially we filter out states that are offline and have a last active more than a week ago, though this can be changed down the line. Fixes #3962
f1be5cb
to
d5a5d1c
Compare
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.
generally looks sane. a few nits.
@@ -220,6 +220,15 @@ def __init__(self, hs): | |||
LaterGauge("synapse_handlers_presence_wheel_timer_size", "", [], | |||
lambda: len(self.wheel_timer)) | |||
|
|||
# Used to handle sending of presence to newly joined users/servers | |||
if hs.config.use_presence: | |||
self.notifier.add_replication_callback(self.notify_new_event) |
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'd love it if the stuff in the notifier could be renamed to be less about "replication", since we seem to be using it for things which aren't replication. Guess we can leave that for another time, though.
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.
lgtm otherwise
50a9e39
to
4e5f0f7
Compare
Entries in current state can be "deleted", so we need to handle the case where the new event_id is None. Introduced in #4942.
Primarily this fixes a bug in the handling of remote users joining a
room where the server sent out the presence for all local users in the
room to all servers in the room.
We also change to using the state delta stream, rather than the
distributor, as it will make it easier to split processing out of the
master process (as well as being more flexible).
Finally, when sending presence states to newly joined servers we filter
out old presence states to reduce the number sent. Initially we filter
out states that are offline and have a last active more than a week ago,
though this can be changed down the line.
Fixes #3962
Note that there a few
TODO
items, but I think they can be solved separately. Certainly I think what we have now is strictly better than what was there before.