summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorAmber H. Brown <hawkowl@atleastfornow.net>2019-07-03 22:39:30 +1000
committerAmber H. Brown <hawkowl@atleastfornow.net>2019-07-03 22:39:30 +1000
commitf4343c7d2bbde2d4b9674a029867bbe0353616e4 (patch)
tree44b29f777ae1418b1c858e2aa7cbbece06bafc70 /synapse/storage
parentMerge remote-tracking branch 'origin/develop' into shhs (diff)
parent1.1.0rc2 (diff)
downloadsynapse-f4343c7d2bbde2d4b9674a029867bbe0353616e4.tar.xz
Merge remote-tracking branch 'origin/develop' into shhs
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/events.py9
-rw-r--r--synapse/storage/registration.py13
2 files changed, 18 insertions, 4 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index fefba39ea1..86f8485704 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -253,7 +253,14 @@ class EventsStore(
         )
 
         # Read the extrems every 60 minutes
-        hs.get_clock().looping_call(self._read_forward_extremities, 60 * 60 * 1000)
+        def read_forward_extremities():
+            # run as a background process to make sure that the database transactions
+            # have a logcontext to report to
+            return run_as_background_process(
+                "read_forward_extremities", self._read_forward_extremities
+            )
+
+        hs.get_clock().looping_call(read_forward_extremities, 60 * 60 * 1000)
 
     @defer.inlineCallbacks
     def _read_forward_extremities(self):
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 983ce13291..13a3d5208b 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -25,6 +25,7 @@ from twisted.internet import defer
 
 from synapse.api.constants import UserTypes
 from synapse.api.errors import Codes, StoreError, ThreepidValidationError
+from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.storage import background_updates
 from synapse.storage._base import SQLBaseStore
 from synapse.types import UserID
@@ -619,9 +620,15 @@ class RegistrationStore(
         )
 
         # Create a background job for culling expired 3PID validity tokens
-        hs.get_clock().looping_call(
-            self.cull_expired_threepid_validation_tokens, THIRTY_MINUTES_IN_MS
-        )
+        def start_cull():
+            # run as a background process to make sure that the database transactions
+            # have a logcontext to report to
+            return run_as_background_process(
+                "cull_expired_threepid_validation_tokens",
+                self.cull_expired_threepid_validation_tokens,
+            )
+
+        hs.get_clock().looping_call(start_cull, THIRTY_MINUTES_IN_MS)
 
     @defer.inlineCallbacks
     def _backgroud_update_set_deactivated_flag(self, progress, batch_size):