[SERVER-37536] shardCollection command updates config.collections metadata for unsharded collections Created: 09/Oct/18  Updated: 27/Oct/23  Resolved: 02/Nov/22

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

Type: Task Priority: Major - P3
Reporter: Misha Tyulenev Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Gone away Votes: 0
Labels: MaxH, pm-1051-legacy-tickets
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-37581 shardCollection command supports conf... Closed
Assigned Teams:
Sharding
Sprint: Sharding 2018-11-19, Sharding 2018-12-03
Participants:

 Description   

Implementation:
1. Add "partitioned": true to this query to correctly check if there is an existing sharded collection.

2. Update config.chunks in _shardsvrShardCollection:
2a. When checking for existing chunks, read in all chunks for this namespace rather than the count if this collection already exists. Assert that there exists only 1 chunk with the correct version (version(1, 0)) and chunk range (globalMin -> globalMax).
2b. When writing the chunks to the config, we should send an update command (rather than an insert). We need to bump the major chunk version here as a part of this update.

3. Update config.collections and set the shardKey to the new shardKey and "sharded: true" here.

Testing:
We need to test this for an empty unsharded collection and a non-empty sharded collection.

Set up:
Empty unsharded collection:
1. Create a collection.
2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": false and dummy shard key), and config.chunks (only one entry with version(1,0) and range (globalMin : globalMax)).

Non-empty unsharded collection:
1. Insert some documents into a collection.
2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": false and dummy shard key), and config.chunks (only one entry with version(1,0) and range (globalMin : globalMax)).

Assert shard collection properly updates the metadata for both empty and non-empty collections:
Run shardCollection with each of the following scenarios:

  • Range based shard key
  • Hashed shard key
  • Hashed shard key and setting numInitialChunks (only for empty collections)
  • Zoned sharding (only for empty collections)

For each of the above scenarios do:
1. Shard the collection.
2. Assert that there exists the correct entries in config.databases, config.collections ("sharded": true and updated shard key), and config.chunks (expected number of chunks for the way in which we sharded the collection this iteration, the version is bumped, and correct ranges for the way in which we sharded the collection this iteration).

Assumptions:

  • The collection already exists and is marked in config.collections with {sharded: false}


 Comments   
Comment by Max Hirschhorn [ 02/Nov/22 ]

This ticket was originally part of PM-1051 but is no longer necessary.

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