Wrap a number of things that run in the background

This will reduce the number of "Starting db connection from sentinel context"
warnings, and will help with our metrics.
This commit is contained in:
Richard van der Hoff 2018-07-25 09:41:12 +01:00
parent 1e5dbdcbb1
commit 371da42ae4
9 changed files with 63 additions and 22 deletions

View file

@ -21,6 +21,7 @@ from canonicaljson import json
from twisted.internet import defer
from synapse.api.errors import StoreError
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
from ._base import Cache, SQLBaseStore
@ -711,6 +712,9 @@ class DeviceStore(SQLBaseStore):
logger.info("Pruned %d device list outbound pokes", txn.rowcount)
return self.runInteraction(
"_prune_old_outbound_device_pokes", _prune_txn
run_as_background_process(
"prune_old_outbound_device_pokes",
self.runInteraction,
"_prune_old_outbound_device_pokes",
_prune_txn,
)