We load+refresh the ChunkManager when the Balancer finds chunks to balance. And then we do it again in the MigrationManager to get collection version information to send with the moveChunk command
- Add a chunkVersion and collectionVersion field in MigrateInfo.
- The balancer chunk selection policy represents chunks it selects to be balanced as MigrateInfo objects, which are sent to the Balancer to schedule.
- Then update MigrationType to serialize/parse for chunkVersion and collectionVersion, so config.migrations documents include them and MigrationManager recovery can build correct MigrateInfo objects to reschedule. (go look at type_migration.h/cpp on github for this – the class was checked in with version serialization/parsing, but it had to be removed later, so the code's already there in the file histories. Same for scoped_migration_request.h/cpp).
- Then, instead of loading up the ChunkManager again, just get the collection version from the MigrateInfo that's used to schedule a specific migration.
- Pull out the ChunkManager code from the MigrationManager, as it is no longer needed if the MigrateInfo has both the chunk and collection versions.
- This looks like it will require some changes to manual moveChunk commands coming through from the mongos. Either the Balancer::rebalanceSingleChunk and Balancer::moveSingleChunk must load the ChunkManager now, or (I think better) the mongos should send chunkVersion and collectionVersion in the _configsvrMoveChunk command through to these balancer functions.