summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-06-04 14:20:08 +0100
committerGitHub <noreply@github.com>2019-06-04 14:20:08 +0100
commitd1d38081a7b667413f0a3b363c5e649d57979def (patch)
treefe0f2b60c7f2d648d84f3ada737d9f2d151babd8
parentAvoid rapidly backing-off a server if we ignore the retry interval (#5335) (diff)
parentFix (diff)
downloadsynapse-d1d38081a7b667413f0a3b363c5e649d57979def.tar.xz
Merge pull request #5324 from matrix-org/erikj/ignore_null
Ignore room state with null bytes in for room stats
-rw-r--r--changelog.d/5324.feature1
-rw-r--r--synapse/storage/stats.py16
2 files changed, 17 insertions, 0 deletions
diff --git a/changelog.d/5324.feature b/changelog.d/5324.feature
new file mode 100644
index 0000000000..01285e965c
--- /dev/null
+++ b/changelog.d/5324.feature
@@ -0,0 +1 @@
+Synapse now more efficiently collates room statistics.
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py
index 1c0b183a56..ff266b09b0 100644
--- a/synapse/storage/stats.py
+++ b/synapse/storage/stats.py
@@ -328,6 +328,22 @@ class StatsStore(StateDeltasStore):
             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},