summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-04-03 17:10:02 +0100
committerErik Johnston <erik@matrix.org>2017-04-03 17:10:02 +0100
commitdc251c74a1aaabb4b7e2386eb9c396940cffa119 (patch)
tree1d0c5a17808802708196cc3a2c1354c29df47777
parentMerge branch 'release-v0.20.0' of github.com:matrix-org/synapse into develop (diff)
downloadsynapse-github/erikj/remove_event_auth.tar.xz
Use event_json to get auth chain rather than using dedicated event_auth table github/erikj/remove_event_auth erikj/remove_event_auth
-rw-r--r--synapse/storage/event_federation.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index 519059c306..04b6010948 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -22,6 +22,7 @@ from unpaddedbase64 import encode_base64
 
 import logging
 from Queue import PriorityQueue, Empty
+import ujson as json
 
 
 logger = logging.getLogger(__name__)
@@ -58,13 +59,22 @@ class EventFederationStore(SQLBaseStore):
         results = set()
 
         base_sql = (
-            "SELECT auth_id FROM event_auth WHERE event_id IN (%s)"
+            "SELECT json FROM event_json WHERE event_id IN (%s)"
         )
 
         front = set(event_ids)
         while front:
             new_front = set()
+
+            # If we happen to have the events in our cache we may as well use
+            # them.
+            ev_map = self._get_events_from_cache(front, allow_rejected=True)
+            for entry in ev_map.itervalues():
+                new_front.update(ev_id for ev_id, _ in entry.event.auth_events)
+                front.discard(entry.event.event_id)
+
             front_list = list(front)
+
             chunks = [
                 front_list[x:x + 100]
                 for x in xrange(0, len(front), 100)
@@ -74,7 +84,9 @@ class EventFederationStore(SQLBaseStore):
                     base_sql % (",".join(["?"] * len(chunk)),),
                     chunk
                 )
-                new_front.update([r[0] for r in txn])
+                for row in txn:
+                    ev = json.loads(row[0])
+                    new_front.update(ev_id for ev_id, _ in ev["auth_events"])
 
             new_front -= results