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

sql: TestReacquireLeaseOnRestart fix #137628

Merged
merged 1 commit into from
Dec 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/sql/catalog/lease/descriptor_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func (t *descriptorState) upsertLeaseLocked(
}
if session != nil {
s.mu.lease.sessionID = session.ID().UnsafeBytes()
// When using session based leasing, if we end up acquiring the same lease again
// nothing needs to be cleaned up or updated. This is because the system.lease
// table does not store any expiry inside the table.
toRelease.sessionID = nil
}
if log.ExpensiveLogEnabled(ctx, 2) {
log.VEventf(ctx, 2, "replaced lease: %s with %s", toRelease, s.mu.lease)
Expand Down
10 changes: 1 addition & 9 deletions pkg/sql/catalog/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,8 @@ func purgeOldVersions(
// Acquire a refcount on the descriptor on the latest version to maintain an
// active lease, so that it doesn't get released when removeInactives()
// is called below. Release this lease after calling removeInactives().
//
// If the lease ends up being expired anyway it's okay to purge all previous
// versions (assuming no one has a ref count). With the session based
// leasing upgrade and tests with zero lease duration, we can have the lease
// expire right after acquiring it. Because renewals are disabled in later
// stages of this migration there is no other mechanism to purge old versions
// 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try reverting this part of the change and check if the test is stable? I think it's causing CI failures

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment above to remove the reference to this error. We no longer have the migration scenario any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Faizan! I removed the comment.

removeInactives(isInactive)
if desc != nil {
t.release(ctx, desc)
Expand Down
Loading