summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-27 13:41:48 +0100
committerOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-27 13:41:48 +0100
commita6c102009e219d93b512f682e5f799037536e3ee (patch)
treef5d4542b8723e913ff52d782395bfb196a8bd851
parentApply minor suggestions from review (diff)
downloadsynapse-a6c102009e219d93b512f682e5f799037536e3ee.tar.xz
Lock tables in upsert fall-backs.
Should not be too much of a performance concern as this code won't be
hit on Postgres, which large deployments should be using.

Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
-rw-r--r--synapse/storage/stats.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py
index c950ab9953..0f3aa6a801 100644
--- a/synapse/storage/stats.py
+++ b/synapse/storage/stats.py
@@ -180,6 +180,7 @@ class StatsStore(StateDeltasStore):
 
             txn.execute(sql, qargs)
         else:
+            self.database_engine.lock_table(txn, table)
             retcols = chain(absolutes.keys(), additive_relatives.keys())
             current_row = self._simple_select_one_txn(
                 txn, table, keyvalues, retcols, allow_none=True
@@ -260,6 +261,7 @@ class StatsStore(StateDeltasStore):
             qargs = chain(additive_relatives.values(), keyvalues.values())
             txn.execute(sql, qargs)
         else:
+            self.database_engine.lock_table(txn, into_table)
             src_row = self._simple_select_one_txn(
                 txn, src_table, keyvalues, copy_columns
             )