summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-11-07 16:46:41 +0000
committerBrendan Abolivier <babolivier@matrix.org>2019-11-07 16:46:41 +0000
commit1186612d6cd728e6b7ed7806579db3cea7410b54 (patch)
treeb4d3087515c9bb46cdf8fb3e174fd13f48124e4d /synapse/storage
parentInitialise value before looping (diff)
downloadsynapse-1186612d6cd728e6b7ed7806579db3cea7410b54.tar.xz
Back to using cursor_to_dict
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/data_stores/main/events_bg_updates.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/synapse/storage/data_stores/main/events_bg_updates.py b/synapse/storage/data_stores/main/events_bg_updates.py
index bee8c9cfa0..b858e3ac1a 100644
--- a/synapse/storage/data_stores/main/events_bg_updates.py
+++ b/synapse/storage/data_stores/main/events_bg_updates.py
@@ -525,10 +525,13 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
                 (last_event_id, batch_size),
             )
 
-            nbrows = 0
-            last_row_event_id = ""
-            for (event_id, event_json_raw) in txn:
-                event_json = json.loads(event_json_raw)
+            rows = self.cursor_to_dict(txn)
+            if not len(rows):
+                return 0
+
+            for row in rows:
+                event_id = row["event_id"]
+                event_json = json.loads(row["event_json"])
 
                 self._simple_insert_many_txn(
                     txn=txn,
@@ -547,14 +550,11 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
                     ],
                 )
 
-                nbrows += 1
-                last_row_event_id = event_id
-
             self._background_update_progress_txn(
-                txn, "event_store_labels", {"last_event_id": last_row_event_id}
+                txn, "event_store_labels", {"last_event_id": event_id}
             )
 
-            return nbrows
+            return len(rows)
 
         num_rows = yield self.runInteraction(
             desc="event_store_labels", func=_event_store_labels_txn