summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-11-01 11:42:08 +0000
committerErik Johnston <erik@matrix.org>2016-11-01 11:42:08 +0000
commit760469c81238f86a4ae6dbb485c9c2f4930a3483 (patch)
treeff43041576f3a3e792dde35bd39bdb3d0dc5cb16 /synapse
parentRemoved unused stuff (diff)
downloadsynapse-760469c81238f86a4ae6dbb485c9c2f4930a3483.tar.xz
Continue to clean up received_transactions
Diffstat (limited to '')
-rw-r--r--synapse/storage/transactions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py
index 59ece7b811..adab520c78 100644
--- a/synapse/storage/transactions.py
+++ b/synapse/storage/transactions.py
@@ -46,6 +46,11 @@ class TransactionStore(SQLBaseStore):
     """A collection of queries for handling PDUs.
     """
 
+    def __init__(self, hs):
+        super(TransactionStore, self).__init__(hs)
+
+        self._clock.looping_call(self._cleanup_transactions, 30 * 60 * 1000)
+
     def get_received_txn_response(self, transaction_id, origin):
         """For an incoming transaction from a given origin, check if we have
         already responded to it. If so, return the response code and response
@@ -234,3 +239,12 @@ class TransactionStore(SQLBaseStore):
 
         txn.execute(query, (self._clock.time_msec(),))
         return self.cursor_to_dict(txn)
+
+    def _cleanup_transactions(self):
+        now = self._clock.time_msec()
+        month_ago = now - 30 * 24 * 60 * 60 * 1000
+
+        def _cleanup_transactions_txn(txn):
+            txn.execute("DELETE FROM received_transactions WHERE ts < ?", (month_ago,))
+
+        return self.runInteraction("_cleanup_transactions", _cleanup_transactions_txn)