summary refs log tree commit diff
path: root/synapse/storage/data_stores
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-11-01 12:03:04 +0000
committerBrendan Abolivier <babolivier@matrix.org>2019-11-04 09:56:11 +0000
commit824bba2f78f86a9364a87c6ce79a40bff0f73cbf (patch)
treefa59324f45713737bbf644b983d86c86c4821fb6 /synapse/storage/data_stores
parentTODO (diff)
downloadsynapse-824bba2f78f86a9364a87c6ce79a40bff0f73cbf.tar.xz
Correctly order results
Diffstat (limited to 'synapse/storage/data_stores')
-rw-r--r--synapse/storage/data_stores/main/events_bg_updates.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/synapse/storage/data_stores/main/events_bg_updates.py b/synapse/storage/data_stores/main/events_bg_updates.py
index b7b390485b..5ba1cff468 100644
--- a/synapse/storage/data_stores/main/events_bg_updates.py
+++ b/synapse/storage/data_stores/main/events_bg_updates.py
@@ -21,7 +21,7 @@ from canonicaljson import json
 
 from twisted.internet import defer
 
-from synapse.api.constants import LabelsField
+from synapse.api.constants import EventContentFields
 from synapse.storage._base import make_in_list_sql_clause
 from synapse.storage.background_updates import BackgroundUpdateStore
 
@@ -520,7 +520,7 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
                 SELECT event_id, json FROM event_json
                 LEFT JOIN event_labels USING (event_id)
                 WHERE event_id > ? AND label IS NULL
-                LIMIT ?
+                ORDER BY event_id LIMIT ?
                 """,
                 (last_event_id, batch_size),
             )
@@ -538,7 +538,9 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
                     table="event_labels",
                     values=[
                         {"event_id": event_id, "label": label}
-                        for label in event_json["content"].get(LabelsField, [])
+                        for label in event_json["content"].get(
+                            EventContentFields.Labels, []
+                        )
                     ],
                 )
 
@@ -548,8 +550,6 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
 
             # We want to return true (to end the background update) only when
             # the query returned with less rows than we asked for.
-            # TODO: this currently doesn't work, i.e. it only runs once whereas
-            #       its opposite does the whole thing, investigate.
             return len(rows) != batch_size
 
         end = yield self.runInteraction(