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

Commit

Permalink
Merge pull request #5324 from matrix-org/erikj/ignore_null
Browse files Browse the repository at this point in the history
Ignore room state with null bytes in for room stats
  • Loading branch information
erikjohnston authored Jun 4, 2019
2 parents df9c100 + 0a56966 commit d1d3808
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

0 comments on commit d1d3808

Please sign in to comment.