summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-05 18:21:19 +0100
committerErik Johnston <erik@matrix.org>2015-05-05 18:21:19 +0100
commit0c4ac271ca2c9e46e20ba9546f0e6f1983d8e923 (patch)
treeaa5af8e6167cffa28a30d5eb329db1203678103c /synapse/storage/events.py
parentDon't insert without deduplication. In this case we never actually use this t... (diff)
parentAnd use buffer(...) there as well (diff)
downloadsynapse-0c4ac271ca2c9e46e20ba9546f0e6f1983d8e923.tar.xz
Merge branch 'erikj/executemany' of github.com:matrix-org/synapse into erikj/SYN-371
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 34bd49cfe9..38395c66ab 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -93,7 +93,7 @@ class EventsStore(SQLBaseStore):
                            current_state=None):
 
         # Remove the any existing cache entries for the event_id
-        self._invalidate_get_event_cache(event.event_id)
+        txn.call_after(self._invalidate_get_event_cache, event.event_id)
 
         if stream_ordering is None:
             with self._stream_id_gen.get_next_txn(txn) as stream_ordering:
@@ -113,19 +113,24 @@ class EventsStore(SQLBaseStore):
                 keyvalues={"room_id": event.room_id},
             )
 
-            self._simple_insert_many_txn(
-                txn,
-                "current_state_events",
-                [
+            for s in current_state:
+                if s.type == EventTypes.Member:
+                    txn.call_after(
+                        self.get_rooms_for_user.invalidate, s.state_key
+                    )
+                    txn.call_after(
+                        self.get_joined_hosts_for_room.invalidate, s.room_id
+                    )
+                self._simple_insert_txn(
+                    txn,
+                    "current_state_events",
                     {
                         "event_id": s.event_id,
                         "room_id": s.room_id,
                         "type": s.type,
                         "state_key": s.state_key,
                     }
-                    for s in current_state
-                ],
-            )
+                )
 
         outlier = event.internal_metadata.is_outlier()
 
@@ -261,7 +266,9 @@ class EventsStore(SQLBaseStore):
         )
 
         if context.rejected:
-            self._store_rejections_txn(txn, event.event_id, context.rejected)
+            self._store_rejections_txn(
+                txn, event.event_id, context.rejected
+            )
 
         for hash_alg, hash_base64 in event.hashes.items():
             hash_bytes = decode_base64(hash_base64)
@@ -273,7 +280,8 @@ class EventsStore(SQLBaseStore):
             for alg, hash_base64 in prev_hashes.items():
                 hash_bytes = decode_base64(hash_base64)
                 self._store_prev_event_hash_txn(
-                    txn, event.event_id, prev_event_id, alg, hash_bytes
+                    txn, event.event_id, prev_event_id, alg,
+                    hash_bytes
                 )
 
         self._simple_insert_many_txn(
@@ -340,9 +348,11 @@ class EventsStore(SQLBaseStore):
                     }
                 )
 
+        return
+
     def _store_redaction(self, txn, event):
         # invalidate the cache for the redacted event
-        self._invalidate_get_event_cache(event.redacts)
+        txn.call_after(self._invalidate_get_event_cache, event.redacts)
         txn.execute(
             "INSERT INTO redactions (event_id, redacts) VALUES (?,?)",
             (event.event_id, event.redacts)