Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Prevent a deadlock in expiration into release/1.14.x #22379

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/22374.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
expiration: Fix a deadlock that could occur when a revocation failure happens while restoring leases on startup.
```
6 changes: 5 additions & 1 deletion vault/expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ func (r *revocationJob) OnFailure(err error) {
r.m.core.metricSink.IncrCounterWithLabels([]string{"expire", "lease_expiration", "error"}, 1, []metrics.Label{metricsutil.NamespaceLabel(r.ns)})

r.m.pendingLock.Lock()
defer r.m.pendingLock.Unlock()
pendingRaw, ok := r.m.pending.Load(r.leaseID)
r.m.pendingLock.Unlock()
if !ok {
r.m.logger.Warn("failed to find lease in pending map for revocation retry", "lease_id", r.leaseID)
return
Expand Down Expand Up @@ -269,15 +269,19 @@ func (r *revocationJob) OnFailure(err error) {
return
}

r.m.pendingLock.Lock()
r.m.markLeaseIrrevocable(r.nsCtx, le, err)
r.m.pendingLock.Unlock()
return
} else {
r.m.logger.Error("failed to revoke lease", "lease_id", r.leaseID, "error", err,
"attempts", pending.revokesAttempted, "next_attempt", newTimer)
}

pending.timer.Reset(newTimer)
r.m.pendingLock.Lock()
r.m.pending.Store(r.leaseID, pending)
r.m.pendingLock.Unlock()
}

func expireLeaseStrategyFairsharing(ctx context.Context, m *ExpirationManager, leaseID string, ns *namespace.Namespace) {
Expand Down