From 2d07bd7fd231536175b0d5cd086896366d83a3a3 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 13 Oct 2025 10:15:47 -0500 Subject: [PATCH] Update TODO list of conflicting areas where we encounter metrics being clobbered (`ApplicationService`) (#19040) These errors are harmless and are a long-standing issue that is just now being logged, see https://github.com/element-hq/synapse/issues/19042 ``` 2025-10-10 15:30:00,026 - synapse.util.metrics - 330 - ERROR - notify_interested_services-0 - Metric named cache_lru_cache__matches_user_in_member_list_example.com already registered for server example.com 2025-10-10 16:30:00.167 2025-10-10 15:30:00,026 - synapse.util.metrics - 330 - ERROR - notify_interested_services-0 - Metric named cache_lru_cache_is_interested_in_room_example.com already registered for server example.com 2025-10-10 16:30:00.167 2025-10-10 15:30:00,025 - synapse.util.metrics - 330 - ERROR - notify_interested_services-0 - Metric named cache_lru_cache_is_interested_in_event_example.com already registered for server example.com 2025-10-10 16:29:15.560 2025-10-10 15:29:15,449 - synapse.util.metrics - 330 - ERROR - notify_interested_services_ephemeral-0 - Metric named cache_lru_cache__matches_user_in_member_list_example.com already registered for server example.com 2025-10-10 16:29:15.560 2025-10-10 15:29:15,449 - synapse.util.metrics - 330 - ERROR - notify_interested_services_ephemeral-0 - Metric named cache_lru_cache_is_interested_in_room_example.com already registered for server example.com ``` --- changelog.d/19040.misc | 1 + synapse/util/metrics.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelog.d/19040.misc diff --git a/changelog.d/19040.misc b/changelog.d/19040.misc new file mode 100644 index 0000000000..9af18fc50e --- /dev/null +++ b/changelog.d/19040.misc @@ -0,0 +1 @@ +Update TODO list of conflicting areas where we encounter metrics being clobbered (`ApplicationService`). diff --git a/synapse/util/metrics.py b/synapse/util/metrics.py index 7b6ad0e459..f71380d689 100644 --- a/synapse/util/metrics.py +++ b/synapse/util/metrics.py @@ -323,9 +323,13 @@ class DynamicCollectorRegistry(CollectorRegistry): if server_hooks.get(metric_name) is not None: # TODO: This should be an `assert` since registering the same metric name # multiple times will clobber the old metric. - # We currently rely on this behaviour as we instantiate multiple - # `SyncRestServlet`, one per listener, and in the `__init__` we setup a new - # LruCache. + # + # We currently rely on this behaviour in a few places: + # - We instantiate multiple `SyncRestServlet`, one per listener, and in the + # `__init__` we setup a new `LruCache`. + # - We instantiate multiple `ApplicationService` (one per configured + # application service) which use the `@cached` decorator on some methods. + # # Once the above behaviour is changed, this should be changed to an `assert`. logger.error( "Metric named %s already registered for server %s",