Skip to content

Commit

Permalink
catalog/lease: prevent panic inside upsertLeaseLocked
Browse files Browse the repository at this point in the history
Previously, it was possible to panic inside upsertLeaseLocked, if the
stored lease was nil. This could happen in tests which are designed to
instantly release dereferenced leases. For example this was seen inside:
TestAsOfSystemTimeUsesCache. To address this, this patch will add
defensive code to check for a valid stored lease, before clearing
the session ID stored inside the lease.

Fixes: #131300

Release note: None
  • Loading branch information
fqazi committed Sep 25, 2024
1 parent 3a544e4 commit 802ccfa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/sql/catalog/lease/descriptor_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ func (t *descriptorState) upsertLeaseLocked(
// is subsumed we have nothing to delete. In dual-write mode clearing
// this guarantees only the old expiry based lease is cleaned up. In
// Session only clearing this means the release is a no-op.
toRelease.sessionID = nil
if toRelease != nil {
toRelease.sessionID = nil
}
return nil, toRelease, nil
}

Expand Down

0 comments on commit 802ccfa

Please sign in to comment.