Fix race that can lead to panic during seal (#23906)

* Fix race that can lead to panic during seal

* Add changelog
This commit is contained in:
Paul Banks
2023-10-30 18:26:33 +00:00
committed by GitHub
parent 66494c8129
commit 063456495a
2 changed files with 7 additions and 4 deletions

3
changelog/23906.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
core: fix rare panic due to a race condition with metrics collection during seal
```

View File

@@ -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()