summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-03 11:28:01 +0100
committerErik Johnston <erik@matrix.org>2018-10-03 11:28:01 +0100
commit7c570bff749eaf72be6f982c89facab3b16c42ae (patch)
treec5e69f7427cc9028aade65575c74433674bfec1f /synapse/metrics
parentMerge pull request #3991 from matrix-org/erikj/fix_pop_retry_cache (diff)
downloadsynapse-7c570bff749eaf72be6f982c89facab3b16c42ae.tar.xz
Fix exception in background metrics collection
We attempted to iterate through a list on a separate thread without
doing the necessary copying.
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/background_process_metrics.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/metrics/background_process_metrics.py b/synapse/metrics/background_process_metrics.py
index 173908299c..037f1c490e 100644
--- a/synapse/metrics/background_process_metrics.py
+++ b/synapse/metrics/background_process_metrics.py
@@ -101,9 +101,13 @@ class _Collector(object):
             labels=["name"],
         )
 
-        # We copy the dict so that it doesn't change from underneath us
+        # We copy the dict so that it doesn't change from underneath us.
+        # We also copy the process lists as that can also change
         with _bg_metrics_lock:
-            _background_processes_copy = dict(_background_processes)
+            _background_processes_copy = {
+                k: list(v)
+                for k, v in six.iteritems(_background_processes)
+            }
 
         for desc, processes in six.iteritems(_background_processes_copy):
             background_process_in_flight_count.add_metric(