Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38392

Remove assertion that we can't shard a non-empty collection associated with tags

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.5, 4.1.7
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • v4.0
    • Sharding 2018-12-17

      When sharding a non-empty collection that is associated with tags, we should create one chunk on the primary shard and let the balancer handle splitting and moving the chunks which is what we do for non-empty collections not associated with tags.

      In order to do this, we should remove this assertion and instead call `InitialSplitPolicy::calculateHashedSplitPointsForEmptyCollection` if `tags.empty`. We should pass `isEmpty` into `shardCollection()`, `InitialSplitPolicy::createFirstChunks`, and `InitialSplitPolicy::generateShardCollectionInitialZonedChunks` so that we can later check whether or not the collection is empty. In `generateShardCollectionInitialZonedChunks`, if `isEmpty` is false, we should just create one chunk by calling `appendChunk(nss, keyPattern.globalMin(), keyPattern.globalMax(), &version, validAfter, allShardIds[0], &chunks)` and not doing any of this.

      To test this, we should enable the balancer in our ShardingTest and then insert into some unsharded collection and create a few zones associated with this collection. We should then call shardCollection and assert that only one chunk exists after. We should then wait some time for the balancer to run and then assert that the chunks were correctly split and moved.

            Assignee:
            kimberly.tao@mongodb.com Kim Tao
            Reporter:
            janna.golden@mongodb.com Janna Golden
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: