summary refs log tree commit diff
path: root/synapse/handlers/stats.py
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2020-08-03 13:54:24 -0700
committerGitHub <noreply@github.com>2020-08-03 21:54:24 +0100
commit5d92a1428ceb4077801afc1785a5472e89fd9df3 (patch)
tree318ff4720ba136d23267d8fa533fd2e9322fd37f /synapse/handlers/stats.py
parentImplement handling of HTTP HEAD requests. (#7999) (diff)
downloadsynapse-5d92a1428ceb4077801afc1785a5472e89fd9df3.tar.xz
Prevent join->join membership transitions changing member count (#7977)
`StatsHandler` handles updates to the `current_state_delta_stream`, and updates room stats such as the amount of state events, joined users, etc.

However, it counts every new join membership as a new user entering a room (and that user being in another room), whereas it's possible for a user's membership status to go from join -> join, for instance when they change their per-room profile information.

This PR adds a check for join->join membership transitions, and bails out early, as none of the further checks are necessary at that point.

Due to this bug, membership stats in many rooms have ended up being wildly larger than their true values. I am not sure if we also want to include a migration step which recalculates these statistics (possibly using the `_populate_stats_process_rooms` bg update).

Bug introduced in the initial implementation https://github.com/matrix-org/synapse/pull/4338.
Diffstat (limited to 'synapse/handlers/stats.py')
-rw-r--r--synapse/handlers/stats.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py
index 149f861239..249ffe2a55 100644
--- a/synapse/handlers/stats.py
+++ b/synapse/handlers/stats.py
@@ -232,7 +232,7 @@ class StatsHandler:
 
                 if membership == prev_membership:
                     pass  # noop
-                if membership == Membership.JOIN:
+                elif membership == Membership.JOIN:
                     room_stats_delta["joined_members"] += 1
                 elif membership == Membership.INVITE:
                     room_stats_delta["invited_members"] += 1