Skip to content

Commit

Permalink
sql: TestReacquireLeaseOnRestart fix
Browse files Browse the repository at this point in the history
Previously we had an extra condition in an if statement which caused
this failure.  This was the condition `errors.Is(err, errRenewLease)`
it is now removed and we now set toRelease to nil when `session != nil`

Fixes: #129421

Release note: none
  • Loading branch information
Dedej-Bergin committed Dec 17, 2024
1 parent 6be7b6f commit 95df273
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pkg/sql/catalog/lease/descriptor_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func (t *descriptorState) upsertLeaseLocked(
}
if session != nil {
s.mu.lease.sessionID = session.ID().UnsafeBytes()
toRelease = nil
}
if log.ExpensiveLogEnabled(ctx, 2) {
log.VEventf(ctx, 2, "replaced lease: %s with %s", toRelease, s.mu.lease)
Expand Down Expand Up @@ -259,8 +260,8 @@ func (t *descriptorState) release(ctx context.Context, s *descriptorVersionState
// when the refcount drops to 0). If so, we'll need to mark the lease as
// invalid.
removeOnceDereferenced :=
// Release from the store if the descriptor has been dropped or taken
// offline.
// Release from the store if the descriptor has been dropped or taken
// offline.
t.mu.takenOffline ||
// Release from the store if the lease is not for the latest
// version; only leases for the latest version can be acquired.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func purgeOldVersions(
// if we hit this case. Note: This scenario is impossible to hit in the real
// world since the lease duration is never set to 0.
desc, _, err := t.findForTimestamp(ctx, m.storage.clock.Now())
if isInactive := catalog.HasInactiveDescriptorError(err); err == nil || isInactive || errors.Is(err, errRenewLease) {
if isInactive := catalog.HasInactiveDescriptorError(err); err == nil || isInactive {
removeInactives(isInactive)
if desc != nil {
t.release(ctx, desc)
Expand Down

0 comments on commit 95df273

Please sign in to comment.