Make global metric trees thread-safe by adding read/write mutex

    • Type: Sub-task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Networking & Observability
    • N&O 2026-03-30, N&O 2026-04-13
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Each mongod and mongos has one global MetricTreeSet via globalMetricTreeSet(), which returns a reference to a process-wide StaticImmortal<MetricTreeSet>.

      • MetricTreeSet/MetricTree do not own a lock that serializes every mutator and reader on those trees.
      • The global trees are populated by MetricBuilder/ CustomMetricBuilder at file scope (startup). It does not enforce init-only registration.

      SERVER-123237 is making MetricsService::create* support registering OTEL metrics to the global MetricTreeSet for serverStatus reporting. Without adding a read/write mutex or some synchronization, OTEL metric creation would only be safe during initialization.

            Assignee:
            Unassigned
            Reporter:
            Cheahuychou Mao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: