It is possible for the splitVector command to return split points that are outside the min/max range that it was told to search, when there is data corruption. This can cause downstream problems for splitChunk (see
To keep potential problems in splitVector contained, it could have one or both of the following sanity checks:
- Have a postcondition that all the split points being returned lie between min (inclusive) and max (exclusive).
- Somewhat equivalently, have a loop invariant that the currKey variable always lies between min and max.
(However, it may be more appropriate to fail the splitVector command, rather than to completely abort the mongod with an fassert/invariant failure.)