If a refine shard key command finishes before this check in the migration recovery runs, this invariant will be triggered. The function findIntersectingChunk uses string comparisons to find the chunk that contains the key. However, the containsKey function uses BSONObj comparison. In the case where a refine shard key has run, the string comparison will return the correct chunk but the bsonobj comparison will fail because there is an extra field in the shard key.
The migration recovery should either specifically handle refine shard key, or the comparisons in findIntersectingChunk and containsKey should be fixed to not return conflicting information.
- is related to
SERVER-53973 Migration manager recovery should handle failed findIntersectingChunk during refineShardKey
SERVER-62332 RefineCollectionShardKeyCoordinator doesn't disallow migrations while it's executing