From 45b733f3d8fbae2cc7080cd1aac69493cb4994a9 Mon Sep 17 00:00:00 2001 From: Paul Banks Date: Mon, 30 Oct 2023 17:36:15 +0000 Subject: [PATCH 1/2] Fix race that can lead to panic during seal --- vault/core_metrics.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vault/core_metrics.go b/vault/core_metrics.go index 022e2fcb7b1..7ceea13c0d5 100644 --- a/vault/core_metrics.go +++ b/vault/core_metrics.go @@ -597,14 +597,14 @@ func (c *Core) inFlightReqGaugeMetric() { // configuredPoliciesGaugeCollector is used to collect gauge label values for the `vault.policy.configured.count` metric func (c *Core) configuredPoliciesGaugeCollector(ctx context.Context) ([]metricsutil.GaugeLabelValues, error) { - if c.policyStore == nil { - return []metricsutil.GaugeLabelValues{}, nil - } - c.stateLock.RLock() policyStore := c.policyStore c.stateLock.RUnlock() + if policyStore == nil { + return []metricsutil.GaugeLabelValues{}, nil + } + ctx = namespace.RootContext(ctx) namespaces := c.collectNamespaces() From 6d4d706b08a42d8f1d16f9f692712ce4bb63753f Mon Sep 17 00:00:00 2001 From: Paul Banks Date: Mon, 30 Oct 2023 17:42:57 +0000 Subject: [PATCH 2/2] Add changelog --- changelog/23906.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/23906.txt diff --git a/changelog/23906.txt b/changelog/23906.txt new file mode 100644 index 00000000000..ed3671dbf42 --- /dev/null +++ b/changelog/23906.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: fix rare panic due to a race condition with metrics collection during seal +```