Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Ignore room state with null bytes in for room stats #5324

Merged
merged 3 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5324.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Synapse now more efficiently collates room statistics.
16 changes: 16 additions & 0 deletions synapse/storage/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,22 @@ def update_room_state(self, room_id, fields):
room_id (str)
fields (dict[str:Any])
"""

# For whatever reason some of the fields may contain null bytes, which
# postgres isn't a fan of, so we replace those fields with null.
for col in (
"join_rules",
"history_visibility",
"encryption",
"name",
"topic",
"avatar",
"canonical_alias"
):
field = fields.get(col)
if field and "\0" in field:
fields[col] = None

return self._simple_upsert(
table="room_state",
keyvalues={"room_id": room_id},
Expand Down