Skip to content

Commit 7a9561e

Browse files
committed
catalog/lease: fix nil pointer dereference in purgeOldVersions
Previously, we added logic that to handle errRenewLease due to session expiration with a debug assertion making sure the latest version of a descriptor was not historical. Sadly, the assertion did not take into account concurrent clean up of the version being retained. To address this, this patch adds an explicit nil check to handle this scenario. Fixes: #154155 Release note: None
1 parent 82a1c7d commit 7a9561e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/sql/catalog/lease/lease.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,11 @@ func (m *Manager) purgeOldVersions(
12771277
}
12781278
// We encountered an error telling us to renew the lease.
12791279
newest := m.findNewest(id)
1280+
// It is possible that a concurrent drop / removal of this descriptor is
1281+
// occurring. If the newest version just doesn't exist, bail out.
1282+
if newest == nil {
1283+
break
1284+
}
12801285
// Assert this should never happen due to a fixed expiration, since the range
12811286
// feed is responsible for purging old versions and acquiring new versions.
12821287
if newest.hasFixedExpiration() {

0 commit comments

Comments
 (0)