The balancer assumes that the sessions collection is always sharded by _id. So the split points it uses are always computed based on _id.id. So if a the sessions collection is dropped, and re-sharded with a shard key other than _id, the balancer will end up creating invalid chunks (the _configsvrCommitChunkSplit command does not verify that the requested split points have the expected shard key pattern). This issue exists in 3.6, 4.0, 4.2 and 4.4 since prior to
SERVER-35804 users are not banned from dropping collections in the config database.
We can solve this by doing one of the following:
- Make getSplitCandidatesForSessionsCollection() not return any candidate chunks or throw an error if the shard key for config.system.sessions collection is not _id.
- Make the _configCommitChunkSplit command validate that the split points have the expected key pattern (currently, it only verifies that the split points came in increasing order and that are not repeated).