summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2016-07-15 13:23:29 +0100
committerGitHub <noreply@github.com>2016-07-15 13:23:29 +0100
commita2d288c6a9f4b6e329cddb75533c3a4d21066829 (patch)
tree68831c2ebd899a7a4af938cb08127fddc1ef7f82
parentMerge pull request #919 from matrix-org/erikj/auth_fix (diff)
parentPull out min stream_ordering from ex_outlier_stream (diff)
downloadsynapse-a2d288c6a9f4b6e329cddb75533c3a4d21066829.tar.xz
Merge pull request #923 from matrix-org/erikj/purge_history
Various purge_history fixes
-rw-r--r--synapse/storage/__init__.py3
-rw-r--r--synapse/storage/events.py12
2 files changed, 13 insertions, 2 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index e93c3de66c..1c93e18f9d 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -92,7 +92,8 @@ class DataStore(RoomMemberStore, RoomStore,
             extra_tables=[("local_invites", "stream_id")]
         )
         self._backfill_id_gen = StreamIdGenerator(
-            db_conn, "events", "stream_ordering", step=-1
+            db_conn, "events", "stream_ordering", step=-1,
+            extra_tables=[("ex_outlier_stream", "event_stream_ordering")]
         )
         self._receipts_id_gen = StreamIdGenerator(
             db_conn, "receipts_linearized", "stream_id"
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index b582942164..59f8061333 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -1411,11 +1411,21 @@ class EventsStore(SQLBaseStore):
                 to_delete
             )
 
+        txn.execute(
+            "SELECT event_id FROM event_backward_extremities WHERE room_id = ?",
+            (room_id,)
+        )
+
+        cur_back_event_ids = [event_id for event_id, in txn.fetchall()]
+
         # Update backward extremeties
         txn.executemany(
             "INSERT INTO event_backward_extremities (room_id, event_id)"
             " VALUES (?, ?)",
-            [(room_id, event_id) for event_id, in new_backwards_extrems]
+            [
+                (room_id, event_id) for event_id, in new_backwards_extrems
+                if event_id not in cur_back_event_ids
+            ]
         )
 
         txn.executemany(