Skip to content

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

@mw5h

Description

@mw5h

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-multitenancyRelated to multi-tenancyC-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions