diff options
author | reivilibre <38398653+reivilibre@users.noreply.github.com> | 2021-07-09 14:12:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 14:12:47 +0100 |
commit | ca9dface8c63ee164979fbed68693a2511c455f7 (patch) | |
tree | 7b13dfcb6a9f295188efa88814c255eed76454ea | |
parent | Switch `application_services_txns.txn_id` to BIGINT (#10349) (diff) | |
download | synapse-ca9dface8c63ee164979fbed68693a2511c455f7.tar.xz |
Fix the user directory becoming broken (and noisy errors being logged) when knocking and room statistics are in use. (#10344)
Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
-rw-r--r-- | changelog.d/10344.bugfix | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/stats.py | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.d/10344.bugfix b/changelog.d/10344.bugfix new file mode 100644 index 0000000000..ab6eb4999f --- /dev/null +++ b/changelog.d/10344.bugfix @@ -0,0 +1 @@ +Fix the user directory becoming broken (and noisy errors being logged) when knocking and room statistics are in use. diff --git a/synapse/storage/databases/main/stats.py b/synapse/storage/databases/main/stats.py index b10bee6daf..59d67c255b 100644 --- a/synapse/storage/databases/main/stats.py +++ b/synapse/storage/databases/main/stats.py @@ -434,7 +434,7 @@ class StatsStore(StateDeltasStore): ] relative_updates = [ - "%(field)s = EXCLUDED.%(field)s + %(table)s.%(field)s" + "%(field)s = EXCLUDED.%(field)s + COALESCE(%(table)s.%(field)s, 0)" % {"table": table, "field": field} for field in additive_relatives.keys() ] @@ -474,7 +474,10 @@ class StatsStore(StateDeltasStore): self.db_pool.simple_insert_txn(txn, table, merged_dict) else: for (key, val) in additive_relatives.items(): - current_row[key] += val + if current_row[key] is None: + current_row[key] = val + else: + current_row[key] += val current_row.update(absolutes) self.db_pool.simple_update_one_txn(txn, table, keyvalues, current_row) @@ -604,6 +607,7 @@ class StatsStore(StateDeltasStore): "invited_members": membership_counts.get(Membership.INVITE, 0), "left_members": membership_counts.get(Membership.LEAVE, 0), "banned_members": membership_counts.get(Membership.BAN, 0), + "knocked_members": membership_counts.get(Membership.KNOCK, 0), "local_users_in_room": len(local_users_in_room), }, ) |