summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-07 11:21:20 +0000
committerErik Johnston <erik@matrix.org>2014-11-07 11:21:20 +0000
commit16a0815fac750863588c3c1f72c5e445d14bbf43 (patch)
tree00293498f5459dbad30c8e8fd061da438aa0e0f2
parentMerge branch 'develop' of github.com:matrix-org/synapse into federation_autho... (diff)
downloadsynapse-16a0815fac750863588c3c1f72c5e445d14bbf43.tar.xz
Fix bug in _get_auth_chain_txn
-rw-r--r--synapse/storage/event_federation.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index 7140ea3d57..d66a49e9f2 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -32,24 +32,21 @@ class EventFederationStore(SQLBaseStore):
         )
 
     def _get_auth_chain_txn(self, txn, event_id):
-        results = set([event_id])
+        results = set()
+
+        base_sql = (
+            "SELECT auth_id FROM event_auth WHERE %s"
+        )
 
         front = set([event_id])
         while front:
-            for ev_id in front:
-                new_front = set()
-                auth_ids = self._simple_select_onecol_txn(
-                    txn,
-                    table="event_auth",
-                    keyvalues={
-                        "event_id": ev_id,
-                    },
-                    retcol="auth_id",
-                )
+            sql = base_sql % (
+                " OR ".join(["event_id=?"] * len(front)),
+            )
 
-                new_front.update(auth_ids)
-            front = new_front
-            new_front.clear()
+            txn.execute(sql, list(front))
+            front = [r[0] for r in txn.fetchall()]
+            results.update(front)
 
         sql = "SELECT * FROM events WHERE event_id = ?"
         rows = []