summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-12 14:47:23 +0100
committerErik Johnston <erik@matrix.org>2015-05-12 14:47:23 +0100
commite4eddf9b367bdd0384f9b834cb8ba75db4804ae1 (patch)
tree3f6934ef16c2766717ae6a965dfc65581cefb9a0
parentFix up _handle_prev_events to not try to insert duplicate rows (diff)
downloadsynapse-e4eddf9b367bdd0384f9b834cb8ba75db4804ae1.tar.xz
We do actually want to delete rows out of event_backward_extremities
-rw-r--r--synapse/storage/event_federation.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index 6773e44688..f807236eb3 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -336,16 +336,23 @@ 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.call_after(
                 self.get_latest_event_ids_in_room.invalidate, room_id
             )