Skip to content

Commit

Permalink
backport of commit 7ec3867 (#24031)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Cabatoff <[email protected]>
  • Loading branch information
1 parent 891eb6f commit 5efc0cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog/24027.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
expiration: Fix fatal error "concurrent map iteration and map write" when collecting metrics from leases.
```
6 changes: 3 additions & 3 deletions vault/expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5efc0cb

Please sign in to comment.