Skip to content

sql: replace TestingDisableTableLeases with AcquireFreshestFromStore#167084

Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-lease.TestingDisableTableLeases
Mar 31, 2026
Merged

sql: replace TestingDisableTableLeases with AcquireFreshestFromStore#167084
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-lease.TestingDisableTableLeases

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Mar 31, 2026

Tests that directly manipulate descriptors via KV and rely on lease.TestingDisableTableLeases() to make changes immediately visible are incompatible with external-process virtual clusters, because the process-global atomic bool doesn't propagate across process boundaries.

Replace the lease disable pattern with explicit lease refresh via AcquireFreshestFromStore after each direct KV descriptor write. The descriptor version bump (already present in most helpers) causes the lease manager to recognize the change, and AcquireFreshestFromStore forces a synchronous refresh. This works across process boundaries because the lease manager reads from KV, which is shared.

For TestInvalidObjects, the lease disable was unnecessary since it uses crdb_internal.unsafe_upsert_descriptor() which goes through the normal SQL descriptor write path that handles leases internally.

Resolves: #166311

Release note: None

Tests that directly manipulate descriptors via KV and rely on
lease.TestingDisableTableLeases() to make changes immediately visible
are incompatible with external-process virtual clusters, because the
process-global atomic bool doesn't propagate across process boundaries.

Replace the lease disable pattern with explicit lease refresh via
AcquireFreshestFromStore after each direct KV descriptor write. The
descriptor version bump (already present in most helpers) causes the
lease manager to recognize the change, and AcquireFreshestFromStore
forces a synchronous refresh. This works across process boundaries
because the lease manager reads from KV, which is shared.

For TestInvalidObjects, the lease disable was unnecessary since it
uses crdb_internal.unsafe_upsert_descriptor() which goes through
the normal SQL descriptor write path that handles leases internally.

Resolves: cockroachdb#166311

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io bot commented Mar 31, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss rafiss marked this pull request as ready for review March 31, 2026 13:50
@rafiss rafiss requested a review from a team as a code owner March 31, 2026 13:50
@rafiss rafiss requested a review from fqazi March 31, 2026 13:51
Copy link
Copy Markdown
Collaborator

@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 reviewed 5 files and all commit messages, and made 3 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on rafiss).


pkg/sql/crdb_internal_test.go line 267 at r1 (raw file):

		return txn.Put(ctx, catalogkeys.MakeDescMetadataKey(s.Codec(), tableDesc.ID), tableDesc.DescriptorProto())
	}); err != nil {
		t.Fatal(err)

Nit: Lets just use require.NoError


pkg/sql/descriptor_mutation_test.go line 104 at r1 (raw file):

	// since we wrote it directly via KV above.
	if err := mt.leaseManager.AcquireFreshestFromStore(ctx, mt.tableDesc.GetID()); err != nil {
		mt.Fatal(err)

Nit: Lets just use require.NoError


pkg/sql/descriptor_mutation_test.go line 169 at r1 (raw file):

	// since we wrote it directly via KV above.
	if err := mt.leaseManager.AcquireFreshestFromStore(ctx, mt.tableDesc.GetID()); err != nil {
		mt.Fatal(err)

Nit: Lets just use require.NoError

Copy link
Copy Markdown
Collaborator

@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.

:lgtm:

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

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Mar 31, 2026

/trunk merge

@trunk-io trunk-io bot merged commit e1eea7d into cockroachdb:master Mar 31, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests using TestingDisableTableLeases + direct KV descriptor writes are incompatible with external-process virtual clusters

3 participants