Skip to content

catalog/lease: handle lease timestamps below GC interval#161878

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:leaseNameGCResolution
Jan 29, 2026
Merged

catalog/lease: handle lease timestamps below GC interval#161878
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:leaseNameGCResolution

Conversation

@fqazi
Copy link
Copy Markdown
Collaborator

@fqazi fqazi commented Jan 27, 2026

Previously, when locked leasing timestamps were used, it was possible for the lease time to fall below the GC interval in some synthetic scenarios during name resolution. To address this, this patch updates the name resolution logic in the lease manager to treat GC errors as missing descriptors at a given timestamp. This forces the system to use the read timestamp correctly.

Fixes: #161220

Release note: None

@fqazi fqazi requested a review from a team as a code owner January 27, 2026 18:51
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@fqazi fqazi force-pushed the leaseNameGCResolution branch from 1d4482b to 01c7e75 Compare January 27, 2026 19:14
@github-actions
Copy link
Copy Markdown
Contributor

Potential Bug(s) Detected

The three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation.

Next Steps:
Please review the detailed findings in the workflow run.

Note: When viewing the workflow output, scroll to the bottom to find the Final Analysis Summary.

After you review the findings, please tag the issue as follows:

  • If the detected issue is real or was helpful in any way, please tag the issue with O-AI-Review-Real-Issue-Found
  • If the detected issue was not helpful in any way, please tag the issue with O-AI-Review-Not-Helpful

@github-actions github-actions Bot added the o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. label Jan 27, 2026
@fqazi fqazi force-pushed the leaseNameGCResolution branch from 01c7e75 to 3d7ef93 Compare January 27, 2026 19:32
@fqazi fqazi added the O-AI-Review-Real-Issue-Found AI reviewer found real issue label Jan 27, 2026
Copy link
Copy Markdown
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

this fix looks good, just had two nits.

@rafiss made 3 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @fqazi).


pkg/sql/catalog/lease/lease.go line 2093 at r1 (raw file):

	var err error
	id, err := m.resolveName(ctx, timestamp.GetTimestamp(), parentID, parentSchemaID, name)
	if err != nil &&

nit: can you simplify this logic so that everything is inside of one top-level if err != nil { ... }. i think this would improve readability.


pkg/sql/catalog/lease/lease_test.go line 4144 at r1 (raw file):

// TestLeaseBeforeGC validates if a lease timestamp for some reason is before
// a GC interval, we correctly fallback to the read timestamp from the txn.
func TestLeaseBeforeGC(t *testing.T) {

we should also unskip TestRestoreAsOfSystemTimeGCBounds as part of this PR, since this is closing the linked issue #161220

(verify the test passes under stress first, see repro notes at #161220 (comment))

Previously, when locked leasing timestamps were used, it was possible
for the lease time to fall below the GC interval in some synthetic
scenarios during name resolution. To address this, this patch updates
the name resolution logic in the lease manager to treat GC errors as
missing descriptors at a given timestamp. This forces the system to use
the read timestamp correctly.

Fixes: cockroachdb#161220

Release note: None
@fqazi fqazi force-pushed the leaseNameGCResolution branch from 3d7ef93 to 580fbc8 Compare January 29, 2026 15:19
Copy link
Copy Markdown
Collaborator Author

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

@fqazi made 1 comment and resolved 1 discussion.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss).


pkg/sql/catalog/lease/lease_test.go line 4144 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

we should also unskip TestRestoreAsOfSystemTimeGCBounds as part of this PR, since this is closing the linked issue #161220

(verify the test passes under stress first, see repro notes at #161220 (comment))

The test was already unskipped via: #161795.

I did confirm after reverting Andrew's PR (and unskipping the test) the issue no longer reproduces under stress.

@fqazi fqazi requested a review from rafiss January 29, 2026 15:24
Copy link
Copy Markdown
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

:lgtm:

@rafiss made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained.

@fqazi fqazi added the backport-26.1.x Flags PRs that need to be backported to 26.1 label Jan 29, 2026
@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Jan 29, 2026

@rafiss TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig Bot commented Jan 29, 2026

@craig craig Bot merged commit 5320aa7 into cockroachdb:master Jan 29, 2026
27 checks passed
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Jan 29, 2026

Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.


Issue #161220: branch-release-26.1.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-26.1.x Flags PRs that need to be backported to 26.1 o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. O-AI-Review-Real-Issue-Found AI reviewer found real issue v26.2.0-prerelease

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backup: TestRestoreAsOfSystemTimeGCBounds failed [potential use of stale sql lease entry]

3 participants