[SERVER-30856] Create Easy Way to Change Shard Key Created: 26/Aug/17  Updated: 20/Sep/17  Resolved: 26/Aug/17

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

Type: Improvement Priority: Major - P3
Reporter: Kevin Rice Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-4000 command to change shard key of a coll... Closed
Participants:

 Description   

This case covers making it easy for users to change a shard key.

In an abstract sense, this would be automation of something that can already be done by very laborious sets of work-by-hand.

db.runCommand() for this "changeShardKey" runs in config or admin database.
It would take as parameters:

  • name of from-database
  • name of to-database
  • name of collection to be re-sharded
  • new shard key

All other collections in the database would be copied as-is

The steps involved are:
1. shut down all operations on the from database, leaving only one mongos running.
2. Create new database with to-database name
3. For the collection to be resharded, create the collection in the new database and shard it according to the key provided.
4. Move sets of records in a parallel fashion so it doesn't take forever.
5. for each other collection in from-database, move sets of records.

This should be a fairly common use case and should not require dumping the entire database to disk with mongodump / mongoexport.



 Comments   
Comment by Kelsey Schubert [ 26/Aug/17 ]

Hi kevin.rice@searshc.com,

Thank you for the feature request. We're tracking the work to provide a command to change the shard key of a collection in SERVER-4000. Please feel free to vote for it and watch it for updates.

Kind regards,
Thomas

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