[SERVER-66270] ExpressionContext::inMongos does not reliably reflect the execution context Created: 05/May/22  Updated: 06/Mar/23

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

Type: Bug Priority: Major - P3
Reporter: Bernard Gorman Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: auto-reverted
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-66295 Replace all the usages of ExpressionC... Open
Problem/Incident
Related
related to SERVER-66307 Set $_generateV2ResumeTokens paramete... Closed
related to SERVER-73832 Consider replacing the use of Cluster... Backlog
related to SERVER-66271 Consider whether ClusterAggregate::ru... Backlog
Assigned Teams:
Query Execution
Operating System: ALL
Backport Requested:
v6.1, v6.0
Participants:
Linked BF Score: 173

 Description   

When creating an ExpressionContext within ClusterAggregate::runAggregate, we unconditionally set the inMongos field to true. We do this because, at the time this code was written, ClusterAggregate was only linked into and available on mongoS.

However, this appears to have changed as a result of SERVER-45389. After this point, ClusterAggregate is linked into mongod and is used by the PeriodicShardedIndexConsistencyChecker, which runs on the config server primary.

Since ClusterAggregate no longer exclusively runs on mongoS, we need a more robust means of setting inMongos.

We should also investigate whether ExpressionContext::fromMongos reliably reflects the execution context.



 Comments   
Comment by Bernard Gorman [ 09/May/22 ]

For context: we found that fixing the inMongos parameter such that it accurately reflected whether or not we were executing on mongoS caused the PeriodicShardedIndexConsistencyChecker to fail. This is because the value of fromMongos in the aggregate command sent to the shards depends on inMongos, and if fromMongos is false then the shards do not include the shard field in the output of the $indexStats stage at the start of the PeriodicShardedIndexConsistencyChecker pipeline, which causes the pipeline's subsequent grouping logic to fail.

We may want to revisit our reliance on fromMongos when deciding whether to output the shard field in the $indexStats stage (and others, such as $currentOp, where the same approach is used).

Comment by xgen-buildbaron-user [ 07/May/22 ]

Ticket re-opened due to revert. noPassthrough began a consistent failure of jstests\noPassthrough\sharded_index_consistency_metrics.js,jstests\noPassthrough\sharded_index_consistency_metrics_stale_version_retries.js

Comment by Githook User [ 07/May/22 ]

Author:

{'name': 'auto-revert-processor', 'email': 'dev-prod-dag@mongodb.com'}

Message: Revert "SERVER-66270 Set ExpressionContext::inMongos to true only on mongos"

This reverts commit 4170c36e4d2551a0f5e7044c63ee9b8a2a5b48b5.
Branch: master
https://github.com/mongodb/mongo/commit/8cc33764380e07c6d2430c45e859ba9eacead4cc

Comment by Githook User [ 07/May/22 ]

Author:

{'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com', 'username': 'banarun'}

Message: SERVER-66270 Set ExpressionContext::inMongos to true only on mongos
Branch: master
https://github.com/mongodb/mongo/commit/4170c36e4d2551a0f5e7044c63ee9b8a2a5b48b5

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