[SERVER-74816] Unnecessary call to `checkOnPrimaryShardForDb' in `attachCursorToPipeline` Created: 14/Mar/23  Updated: 29/Oct/23  Resolved: 07/Aug/23

Status: Closed
Project: Core Server
Component/s: Query Execution, Sharding
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Ivan Fefer
Resolution: Fixed Votes: 0
Labels: pm3229-m1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-75643 Not all paths of AutoGetCollectionFor... Closed
depends on SERVER-76937 Investigate failing $unionWith tests ... Closed
Assigned Teams:
Sharding EMEA
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding EMEA 2023-03-20, Sharding EMEA 2023-04-03, Sharding EMEA 2023-04-17, Sharding EMEA 2023-05-01, QE 2023-08-07, QE 2023-08-21
Participants:

 Description   

When the attachCursorToPipeline method gets to perform routing and it discovers that the collection is UNSHARDED, it will attempt to take the optimised path, establishing cursors locally, though DBDirectClient, instead of making a remote call.

In order to do this, it sets the expected state of the collection correctly on the OpCtx, and then makes a call, which eventually will enter in the shard role. Since this call will already ensure that the cursors are established on the right shard, by virtue of entering the shard role and the checks that this involves, it is unnecessary (and wrong by itself) to call checkOnPrimaryShardForDb, because that check can be invalid as soon as that function returns.



 Comments   
Comment by Githook User [ 07/Aug/23 ]

Author:

{'name': 'Ivan Fefer', 'email': 'ivan.fefer@mongodb.com', 'username': 'Fefer-Ivan'}

Message: SERVER-74816 Use cm to check for db primary and remove checkOnPrimaryShardForDb
Branch: master
https://github.com/mongodb/mongo/commit/1aa6cc2c2ef07dfd1daefb0c4aea8be382291788

Comment by David Storch [ 01/Aug/23 ]

I think MongoProcessInterface::checkOnPrimaryShardForDb() should be deleted entirely as part of this ticket. If I'm not mistaken, the caller mentioned here is actually the only caller.

Comment by Kevin Cherkauer [ 14/Mar/23 ]

kaloian.manassiev@mongodb.com  Is your PR https://github.com/10gen/mongo/pull/11215 fixing the same problem as BF-27740 was opened for (SERVER-74380)? That failure happened somewhere under the same lambda function your PR is removing the bad call from.

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