diff --git a/changelog/24027.txt b/changelog/24027.txt new file mode 100644 index 0000000000..d276928f93 --- /dev/null +++ b/changelog/24027.txt @@ -0,0 +1,3 @@ +```release-note:bug +expiration: Fix fatal error "concurrent map iteration and map write" when collecting metrics from leases. +``` diff --git a/vault/expiration.go b/vault/expiration.go index cf205d0e07..c62eed9808 100644 --- a/vault/expiration.go +++ b/vault/expiration.go @@ -884,7 +884,7 @@ func (m *ExpirationManager) Stop() error { // for the next ExpirationManager to handle them. newStrategy := ExpireLeaseStrategy(expireNoop) m.expireFunc.Store(&newStrategy) - oldPending := m.pending + oldPending := &m.pending m.pending, m.nonexpiring, m.irrevocable = sync.Map{}, sync.Map{}, sync.Map{} m.leaseCount = 0 m.uniquePolicies = make(map[string][]string) @@ -2490,7 +2490,7 @@ func (m *ExpirationManager) WalkTokens(walkFn ExpirationWalkFunction) error { } m.pendingLock.RLock() - toWalk := []sync.Map{m.pending, m.nonexpiring} + toWalk := []*sync.Map{&m.pending, &m.nonexpiring} m.pendingLock.RUnlock() for _, m := range toWalk { @@ -2519,7 +2519,7 @@ func (m *ExpirationManager) walkLeases(walkFn leaseWalkFunction) error { } m.pendingLock.RLock() - toWalk := []sync.Map{m.pending, m.nonexpiring} + toWalk := []*sync.Map{&m.pending, &m.nonexpiring} m.pendingLock.RUnlock() for _, m := range toWalk {