The _id values for documents in config.chunks and config.tags are currently a concatenation of each document’s namespace and minimum bound. Refining a shard key will change the minimum bound, and because _id is immutable, this would require a delete and insert for each document. To allow updating every document in each collection with a single multi-update, the _id values for these documents will be changed to be auto-generated object ids.
- Remove all uses of ChunkType::genId() and replace any queries on _id with equivalent queries on ns and min, which should use the existing min_1_ns_1 index.
- Store a chunk's _id as a new OID member variable in ChunkType, which corresponds to the existing "name" BSONField
- e.g. make _id the return value of ChunkType::getName() and allow setting it through ChunkType::setName()
- Add a new parser to ChunkType that will not throw if the _id is not found in the given BSONObj and use it in BalanceChunkRequestType::parseFromConfigCommand()
- Change moveChunk, mergeChunk, and splitChunk to use the generated _ids of the involved chunks when constructing the updates to config.chunks for their applyOps commands and make splitChunk use OID::gen() to generate _ids for new chunks (necessary because splitChunk uses an upsert to create new chunks)
- Replace config.tags queries on _id with equivalent queries on ns and min, which should use the existing min_1_ns_1 index.
- Move the logic from ChunkType::genId() to a new method on MigrationType so MigrationType can continue generating its _id by concatenating namespace and min bound.