[SERVER-76937] Investigate failing $unionWith tests when `checkOnPrimaryShardForDb` is removed Created: 09/May/23  Updated: 27/Oct/23  Resolved: 02/Aug/23

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

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

Issue Links:
Depends
is depended on by SERVER-74816 Unnecessary call to `checkOnPrimarySh... Closed
Assigned Teams:
Sharding EMEA
Sprint: QE 2023-08-07
Participants:

 Description   

The code in attachCursorToPipeline performs routing and when it thinks 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 (namely db primary and shard version), it is unnecessary (and wrong by itself) to call checkOnPrimaryShardForDb, because that check can be invalid as soon as that function returns.

When this line is removed, however, there are failures in some $unionWith tests, which indicates that there are places where query doesn't correctly perform shard version checking.

The goal of this ticket is to investigate and fix the respective query bugs as a prerequisite for SERVER-74816.



 Comments   
Comment by Ivan Fefer [ 02/Aug/23 ]

After investigation, we concluded that db primary check is currently required in this place, so I am going to close this ticket and re-open the dependent one. 

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