-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Summary
Tests that directly manipulate table descriptors via KV writes and rely on lease.TestingDisableTableLeases() to make those changes immediately visible to the SQL layer are incompatible with external-process virtual cluster injection.
TestingDisableTableLeases() sets a process-global atomic bool that only takes effect within the test process. When an external-process virtual cluster is metamorphically injected, the external SQL server's lease manager still caches descriptors normally and never sees the direct KV writes. This causes intermittent failures where the SQL layer uses stale descriptors.
Background
Before October 2025, the entire pkg/sql test package had a package-wide override in main_test.go disabling test tenant injection (TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(76378)). In 3f64b0eb656, this override was removed and test tenants were enabled for pkg/sql. Tests affected by this issue weren't caught in that pass, and since tenant injection is metamorphic, failures are intermittent.
Affected tests (known so far)
TestOldBitColumnMetadata(pkg/sql/crdb_internal_test.go)TestInvalidObjects(pkg/sql/crdb_internal_test.go)TestOperationsWithIndexMutation(pkg/sql/descriptor_mutation_test.go)TestDeletePreservingIndexes(pkg/sql/delete_preserving_index_test.go)TestGCJobWithDeletePreservingIndexes(pkg/sql/delete_preserving_index_test.go)TestIndexMutationKVOps(pkg/sql/index_mutation_test.go)
Current fix
These tests are currently pinned to TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet in #166108.
A proper fix would require making TestingDisableTableLeases work across process boundaries (e.g., via a cluster setting or test-only RPC), or refactoring these tests to not rely on disabling the lease manager.
Related to #76378.
Jira issue: CRDB-61853