[SERVER-38392] Remove assertion that we can't shard a non-empty collection associated with tags Created: 04/Dec/18  Updated: 29/Oct/23  Resolved: 12/Dec/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.0.5, 4.1.7

Type: Bug Priority: Major - P3
Reporter: Janna Golden Assignee: Kim Tao
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Sharding 2018-12-17
Participants:
Case:

 Description   

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.



 Comments   
Comment by Githook User [ 12/Dec/18 ]

Author:

{'name': 'Kim Tao', 'email': 'kimbery.tao@10gen.com'}

Message: SERVER-38392: remove assertion that we can't shard a non-empty collection associated with tags

(cherry picked from commit 778f905b2905c00b6f394d8db6e7d12e87d7ad3d)
Branch: v4.0
https://github.com/mongodb/mongo/commit/5a4fa1d1d7bb23939c104432bb8297778a69e7cc

Comment by Githook User [ 11/Dec/18 ]

Author:

{'name': 'Kim Tao', 'email': 'kimbery.tao@10gen.com'}

Message: SERVER-38392: remove assertion that we can't shard a non-empty collection associated with tags
Branch: master
https://github.com/mongodb/mongo/commit/778f905b2905c00b6f394d8db6e7d12e87d7ad3d

Generated at Thu Feb 08 04:48:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.