testMissingShardKeyIndexForType fails due to unpopulated shard catalog cache

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Cluster Scalability
    • Fully Compatible
    • ALL
    • ClusterScalability 16Mar-30Mar
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Root Cause

      testMissingShardKeyIndexForType shards a collection via mongos admin commands but never sends a routed CRUD operation to the shard, so the shard's local catalog cache (config.cache.collections) is never refreshed from the config server.

      When the range deleter script queries the cache on the shard, the entry doesn't exist yet, so it throws "Collection not found in config.cache.collections" before ever reaching the shard key index check. The test expects the error "No index found for shard key" and fails the assertion. Because the assertion throws, the cleanup code (coll.drop()) is skipped, leaving a sharded collection with a dropped index that triggers a secondary metadata consistency hook failure.

      Proposed Fix

      • After sharding the collection, explicitly refresh the shard's catalog cache before running the range deleter script. This ensures the shard knows about the collection's routing metadata before the script tries to look it up. _flushRoutingTableCacheUpdates is used across the sharding tests for this.
      • Ensure test cleanup (dropping the collection) always runs regardless of assertion failures, so the metadata consistency hook doesn't report false inconsistencies.

            Assignee:
            Rehan Gill
            Reporter:
            Rehan Gill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: