As part of SERVER-77079, the lookupQuerySettingsForFind was made to rely on the intialisation status of sharding in order to decide from where to pick up the query settings for a find.
Instead of relying on ShardingState API, we should check if the request comes from the internal Client. There are already similar checks throughout the codebase, such as:
bool isInternalClient(OperationContext* opCtx) {
return opCtx->getClient()->session() && opCtx->getClient()->isInternalClient();
}
We should do the same as part of this ticket.
Apart from that we should prioritize the IDHACK check, before anything else. This would speed up some of the industry workloads which run IDHACK queries, by not doing any unnecessary work (such as ShardingState check). (see screenshot)
We should also put the serializationContext, right before the lookup call
auto serializationContext = parsedFind.findCommandRequest->getSerializationContext();