summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-11-07 16:18:40 +0000
committerBrendan Abolivier <babolivier@matrix.org>2019-11-07 16:18:40 +0000
commitec2cb9f29829cf81f843124ef4289bc0eb88413e (patch)
tree38a0ee795ba3cc05693918695bb3888848fb0fbd
parentIncorporate review (diff)
downloadsynapse-ec2cb9f29829cf81f843124ef4289bc0eb88413e.tar.xz
Initialise value before looping
-rw-r--r--synapse/storage/data_stores/main/events_bg_updates.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/synapse/storage/data_stores/main/events_bg_updates.py b/synapse/storage/data_stores/main/events_bg_updates.py
index 9714662c11..bee8c9cfa0 100644
--- a/synapse/storage/data_stores/main/events_bg_updates.py
+++ b/synapse/storage/data_stores/main/events_bg_updates.py
@@ -526,28 +526,32 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
             )
 
             nbrows = 0
-            for (event_id, event_json) in txn:
+            last_row_event_id = ""
+            for (event_id, event_json_raw) in txn:
+                event_json = json.loads(event_json_raw)
+
                 self._simple_insert_many_txn(
                     txn=txn,
                     table="event_labels",
                     values=[
                         {
                             "event_id": event_id,
-                            "label": str(label),
+                            "label": label,
                             "room_id": event_json["room_id"],
                             "topological_ordering": event_json["depth"],
                         }
                         for label in event_json["content"].get(
                             EventContentFields.LABELS, []
                         )
-                        if label is not None
+                        if label is not None and isinstance(label, str)
                     ],
                 )
 
                 nbrows += 1
+                last_row_event_id = event_id
 
             self._background_update_progress_txn(
-                txn, "event_store_labels", {"last_event_id": event_id}
+                txn, "event_store_labels", {"last_event_id": last_row_event_id}
             )
 
             return nbrows