Skip to content

Commit 5efc0cb

Browse files
backport of commit 7ec3867 (#24031)
Co-authored-by: Nick Cabatoff <[email protected]>
1 parent 891eb6f commit 5efc0cb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

changelog/24027.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
expiration: Fix fatal error "concurrent map iteration and map write" when collecting metrics from leases.
3+
```

vault/expiration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ func (m *ExpirationManager) Stop() error {
884884
// for the next ExpirationManager to handle them.
885885
newStrategy := ExpireLeaseStrategy(expireNoop)
886886
m.expireFunc.Store(&newStrategy)
887-
oldPending := m.pending
887+
oldPending := &m.pending
888888
m.pending, m.nonexpiring, m.irrevocable = sync.Map{}, sync.Map{}, sync.Map{}
889889
m.leaseCount = 0
890890
m.uniquePolicies = make(map[string][]string)
@@ -2490,7 +2490,7 @@ func (m *ExpirationManager) WalkTokens(walkFn ExpirationWalkFunction) error {
24902490
}
24912491

24922492
m.pendingLock.RLock()
2493-
toWalk := []sync.Map{m.pending, m.nonexpiring}
2493+
toWalk := []*sync.Map{&m.pending, &m.nonexpiring}
24942494
m.pendingLock.RUnlock()
24952495

24962496
for _, m := range toWalk {
@@ -2519,7 +2519,7 @@ func (m *ExpirationManager) walkLeases(walkFn leaseWalkFunction) error {
25192519
}
25202520

25212521
m.pendingLock.RLock()
2522-
toWalk := []sync.Map{m.pending, m.nonexpiring}
2522+
toWalk := []*sync.Map{&m.pending, &m.nonexpiring}
25232523
m.pendingLock.RUnlock()
25242524

25252525
for _, m := range toWalk {

0 commit comments

Comments
 (0)