[SERVER-66295] Replace all the usages of ExpressionContext::inMongos with isMongos() Created: 06/May/22  Updated: 06/Dec/22

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Arun Banala Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-66270 ExpressionContext::inMongos does not ... Open
Related
Assigned Teams:
Query Execution
Participants:

 Description   

We don't need the inMongos as a parameter of ExpressionContext. We can get this information from the mongo::isMongos() helper. We should get rid of inMongos in ExpressionContext and replace all the usages with isMongos() helper.



 Comments   
Comment by Kaloian Manassiev [ 09/May/22 ]

I can kind of see the value in (1). However, for (2), how do you know that the root operation that sets $_generateV2ResumeTokens isn't running as a router role on a MongoS and doesn't need to set that value as well? Not only MongoS nodes need to necessarily run as routers.

Comment by Arun Banala [ 09/May/22 ]

kaloian.manassiev@mongodb.com There are a couple of cases that I can think of where we currently need to know to type of the node. (1) a $group or $sort may want to use disk for spilling. So we have to check whether we are running on mongos or mongod to verify this. (2) If we want to set certain internal parameter only on the client request (as was the case for $_generateV2ResumeTokens parameter). The query code currently assumes that the inMongos is only being set on a mongos node. As noted in SERVER-66270, it looks like PeriodicShardedIndexConsistencyChecker broke this assumption, as it is calling the ClusterAggregate::runAggregate() from a mongod node. Now the inMongos (as a consequence fromMongos) parameters are overloaded, as the rest of the code is using it to check the node type.

Comment by Kaloian Manassiev [ 08/May/22 ]

What is the reason for having to ask whether a code is running within MongoS or not? Both MongoD and MongoS can have the router role, so whether something is MongoS should be irrelevant.

Generated at Thu Feb 08 06:05:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.