diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-07-25 11:54:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 11:54:33 +0100 |
commit | 1bfb5bed1d50f8e02e0baad63b94708ece78dacc (patch) | |
tree | 9624d14b6622584e27f9bd3ae84dfaf4dd8b7ab2 /synapse/storage/transactions.py | |
parent | Merge pull request #3597 from matrix-org/erikj/did_forget (diff) | |
parent | Fix unit tests (diff) | |
download | synapse-1bfb5bed1d50f8e02e0baad63b94708ece78dacc.tar.xz |
Merge pull request #3604 from matrix-org/rav/background_process_fixes
Wrap a number of things that run in the background
Diffstat (limited to 'synapse/storage/transactions.py')
-rw-r--r-- | synapse/storage/transactions.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index c3bc94f56d..b4b479d94c 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -22,6 +22,7 @@ from canonicaljson import encode_canonical_json, json from twisted.internet import defer +from synapse.metrics.background_process_metrics import run_as_background_process from synapse.util.caches.descriptors import cached from ._base import SQLBaseStore @@ -57,7 +58,7 @@ class TransactionStore(SQLBaseStore): def __init__(self, db_conn, hs): super(TransactionStore, self).__init__(db_conn, hs) - self._clock.looping_call(self._cleanup_transactions, 30 * 60 * 1000) + self._clock.looping_call(self._start_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 @@ -271,6 +272,9 @@ class TransactionStore(SQLBaseStore): txn.execute(query, (self._clock.time_msec(),)) return self.cursor_to_dict(txn) + def _start_cleanup_transactions(self): + run_as_background_process("cleanup_transactions", self._cleanup_transactions) + def _cleanup_transactions(self): now = self._clock.time_msec() month_ago = now - 30 * 24 * 60 * 60 * 1000 |