sql: replace TestingDisableTableLeases with AcquireFreshestFromStore#167084
Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom Mar 31, 2026
Merged
Conversation
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>
Contributor
|
😎 Merged successfully - details. |
Member
fqazi
approved these changes
Mar 31, 2026
Collaborator
fqazi
left a comment
There was a problem hiding this comment.
@fqazi reviewed 5 files and all commit messages, and made 3 comments.
Reviewable status: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
fqazi
approved these changes
Mar 31, 2026
Collaborator
fqazi
left a comment
There was a problem hiding this comment.
@fqazi made 1 comment.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on rafiss).
Collaborator
Author
|
/trunk merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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