summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-05-06 11:25:58 +0100
committerErik Johnston <erik@matrix.org>2016-05-06 11:25:58 +0100
commit1d275dba69272f6df5a79871dc4b8d31e71514d0 (patch)
treea7719facaf210151f01818faadaa64fdd9f50415 /synapse/storage
parentReduce database inserts when sending transactions (diff)
downloadsynapse-1d275dba69272f6df5a79871dc4b8d31e71514d0.tar.xz
Don't needlessly enter transaction
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/transactions.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py
index 17fc601983..ba1969b243 100644
--- a/synapse/storage/transactions.py
+++ b/synapse/storage/transactions.py
@@ -159,10 +159,8 @@ class TransactionStore(SQLBaseStore):
 
         self.inflight_transactions.setdefault(destination, {})[transaction_id] = txn_row
 
-        # TODO: Fetch prev_txns
-
         return self.runInteraction(
-            "prep_send_transaction",
+            "_get_prevs_txn",
             self._get_prevs_txn,
             destination,
         )
@@ -350,11 +348,12 @@ class TransactionStore(SQLBaseStore):
             ]
 
             def f(txn):
-                self._simple_insert_many_txn(
-                    txn=txn,
-                    table="sent_transactions",
-                    values=full_rows
-                )
+                if full_rows:
+                    self._simple_insert_many_txn(
+                        txn=txn,
+                        table="sent_transactions",
+                        values=full_rows
+                    )
 
                 for dest, txn_map in update_delivered.items():
                     for txn_id, update_row in txn_map.items():
@@ -371,6 +370,7 @@ class TransactionStore(SQLBaseStore):
                             }
                         )
 
-            yield self.runInteraction("_persist_in_mem_txns", f)
+            if full_rows or update_delivered:
+                yield self.runInteraction("_persist_in_mem_txns", f)
         except:
             logger.exception("Failed to persist transactions!")