Skip to content

catalog/lease: deflake TestLeaseManagerLockedTimestampCluster#166190

Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:TestLeaseManagerLockedTimestampClusterDeflake
Mar 19, 2026
Merged

catalog/lease: deflake TestLeaseManagerLockedTimestampCluster#166190
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:TestLeaseManagerLockedTimestampClusterDeflake

Conversation

@fqazi
Copy link
Copy Markdown
Collaborator

@fqazi fqazi commented Mar 19, 2026

The test was flaking because it used TestingDescriptorUpdateEvent, which fires before a new version of a descriptor is accquired. To address this, we switch to TestingDescriptorRefreshedEvent, which fires when a new version of a descriptor is acquired. This helps the test become less flakey, because we guarantee that new versions are fully acquired before getting blocked on a channel. Additionally, one of the assertDescriptorCount was in a place where a older timestamp could be acquired, so the assertion itself was race condition prone.

Fixes #165857
Fixes: #166081

Release note: None

@fqazi fqazi requested a review from a team as a code owner March 19, 2026 17:23
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented Mar 19, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@cockroach-teamcity cockroach-teamcity added the X-perf-gain Microbenchmarks CI: Added if a performance gain is detected label Mar 19, 2026
@rafiss rafiss added backport-26.1.x Flags PRs that need to be backported to 26.1 backport-26.2.x Flags PRs that need to be backported to 26.2 labels Mar 19, 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.

nice fix!

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


-- commits line 2 at r1:
nit: ctalog


-- commits line 5 at r1:
nit: accquired -> acquired


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

		require.NotNil(t, newest)
		lastVersion := newest.GetVersion()
		t.Helper()

nit: t.Helper should be the first line of the function. though in this case, i don't think we should use t.Helper at all; it will hide which line failed.


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

		<-newVersionCh
		newest, _ = lm.findNewest(descpb.ID(id))
		// Ensure that the new version is accuired. To avoid any race

nit: accuired -> acquired


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

		releaseNextVersion = true
	}
	// Initial state we only expect a single version.

nit: use a sentence; "In the initial state we only expect a single version."

The test was flaking because it used TestingDescriptorUpdateEvent, which
fires before a new version of a descriptor is acquired. To address
this, we switch to TestingDescriptorRefreshedEvent, which fires when a
new version of a descriptor is acquired. This helps the test become less
flakey, because we guarantee that new versions are fully acquired before
getting blocked on a channel. Additionally, one of the
assertDescriptorCount was in a place where a older timestamp could be
acquired, so the assertion itself was race condition prone.

Fixes: cockroachdb#166081

Release note: None
@fqazi fqazi force-pushed the TestLeaseManagerLockedTimestampClusterDeflake branch from 4aaedbd to 26c37ed Compare March 19, 2026 21:43
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 resolved 5 discussions.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on rafiss).

@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Mar 19, 2026

@rafiss TFTR

/trunk merge

@trunk-io trunk-io Bot merged commit bfad2db into cockroachdb:master Mar 19, 2026
26 checks passed
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Mar 19, 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 #166081: branch-release-26.2.


Issue #165857: branch-release-26.1, branch-release-26.2.


🦉 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 backport-26.2.x Flags PRs that need to be backported to 26.2 target-release-26.3.0 X-perf-gain Microbenchmarks CI: Added if a performance gain is detected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql/catalog/lease: TestLeaseManagerLockedTimestampCluster failed sql/catalog/lease: TestLeaseManagerLockedTimestampCluster failed

3 participants