summary refs log tree commit diff
path: root/synapse/storage/stream.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-03 17:30:00 +0100
committerErik Johnston <erik@matrix.org>2016-06-03 17:30:00 +0100
commitf6be734be9b784bc26a3a23e72061d7b1804efa0 (patch)
tree89a0ecfabd3267d7a5d7bc6c21d495d5f520c0aa /synapse/storage/stream.py
parentMerge pull request #834 from matrix-org/dbkr/fix_email_from (diff)
parentRemove event fetching from DB threads (diff)
downloadsynapse-f6be734be9b784bc26a3a23e72061d7b1804efa0.tar.xz
Merge pull request #835 from matrix-org/erikj/get_event_txn
Remove event fetching from DB threads
Diffstat (limited to 'synapse/storage/stream.py')
-rw-r--r--synapse/storage/stream.py34
1 files changed, 15 insertions, 19 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 95b12559a6..b9ad965fd6 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -132,29 +132,25 @@ class StreamStore(SQLBaseStore):
                         return True
                 return False
 
-            ret = self._get_events_txn(
-                txn,
-                # apply the filter on the room id list
-                [
-                    r["event_id"] for r in rows
-                    if app_service_interested(r)
-                ],
-                get_prev_content=True
-            )
+            return [r for r in rows if app_service_interested(r)]
 
-            self._set_before_and_after(ret, rows)
+        rows = yield self.runInteraction("get_appservice_room_stream", f)
 
-            if rows:
-                key = "s%d" % max(r["stream_ordering"] for r in rows)
-            else:
-                # Assume we didn't get anything because there was nothing to
-                # get.
-                key = to_key
+        ret = yield self._get_events(
+            [r["event_id"] for r in rows],
+            get_prev_content=True
+        )
 
-            return ret, key
+        self._set_before_and_after(ret, rows, topo_order=from_id is None)
 
-        results = yield self.runInteraction("get_appservice_room_stream", f)
-        defer.returnValue(results)
+        if rows:
+            key = "s%d" % max(r["stream_ordering"] for r in rows)
+        else:
+            # Assume we didn't get anything because there was nothing to
+            # get.
+            key = to_key
+
+        defer.returnValue((ret, key))
 
     @defer.inlineCallbacks
     def get_room_events_stream_for_rooms(self, room_ids, from_key, to_key, limit=0,