summary refs log tree commit diff
path: root/synapse/storage/event_federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-12 15:02:53 +0100
committerErik Johnston <erik@matrix.org>2015-05-12 15:02:53 +0100
commit8b28209c6050656b998f7eb7fab8ac55ae9b019b (patch)
tree6f2191ce8d2d3295baee988030dc478d7493a384 /synapse/storage/event_federation.py
parentNewlines (diff)
downloadsynapse-8b28209c6050656b998f7eb7fab8ac55ae9b019b.tar.xz
Err, delete the right stuff
Diffstat (limited to 'synapse/storage/event_federation.py')
-rw-r--r--synapse/storage/event_federation.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index 7ea0ee2323..a1982dfbb5 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -336,20 +336,21 @@ class EventFederationStore(SQLBaseStore):
                 " SELECT 1 FROM event_backward_extremities"
                 " WHERE event_id = ? AND room_id = ?"
                 " )"
+                " AND NOT EXISTS ("
+                " SELECT 1 FROM events WHERE event_id = ? AND room_id = ?"
+                " )"
             )
 
             txn.executemany(query, [
-                (e_id, room_id, e_id, room_id, )
+                (e_id, room_id, e_id, room_id, e_id, room_id, )
                 for e_id, _ in prev_events
             ])
 
-            # Also delete from the backwards extremities table all ones that
-            # reference events that we have already seen
             query = (
                 "DELETE FROM event_backward_extremities"
                 " WHERE event_id = ? AND room_id = ?"
             )
-            txn.executemany(query, [(e_id, room_id) for e_id, _ in prev_events])
+            txn.execute(query, (event_id, room_id))
 
             txn.call_after(
                 self.get_latest_event_ids_in_room.invalidate, room_id