A primary mongod will reject a query inside handlePossibleShardedMessage() by first checking shardingState.enabled() (
https://github.com/mongodb/mongo/blob/master/src/mongo/s/d_logic.h#L252). If it's not enabled, the version check, shardVersionOk, is not performed.
In ReplSetImpl::relinquish(), the last thing we do is call shardingState.resetShardingState(), which clears out shardingState, and most notably, turns off shardingState.enabled().
If I'm not missing something, then if a mongos queries a secondary with a stale version of the config, the secondary has no way to know that and respond accordingly. If I am missing something, could someone please explain it to me?
--
Cheers,
Leif