[SERVER-80194] In sharded_agg_helpers.cpp we retrieve CollectionRoutingInfo without checking for transaction Created: 17/Aug/23  Updated: 29/Oct/23  Resolved: 22/Aug/23

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

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

Issue Links:
Problem/Incident
is caused by SERVER-77427 Avoid going through the network when ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2023-08-21, QE 2023-09-04
Participants:

 Description   

We now use CollectionRoutingInfo, provided by CollectionRouter for out shard targeting: https://github.com/mongodb/mongo/blob/5c14aa402e3cbab58d8de1e891f00e91deb023e5/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L1797

But we used to call getExecutionNsRoutingInfo function instead:

https://github.com/mongodb/mongo/blob/5c14aa402e3cbab58d8de1e891f00e91deb023e5/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L851

The core difference is that it accounts for snapshot isolation transactions: https://github.com/mongodb/mongo/blob/5c14aa402e3cbab58d8de1e891f00e91deb023e5/src/mongo/s/cluster_commands_helpers.cpp#L791

We should add a test to check if there is a problem and fix it.



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

Author:

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

Message: SERVER-80194 Fix subpipeline targeting
Branch: master
https://github.com/mongodb/mongo/commit/d0bc2ec9e1fa0b0c998f8af03e91df97b48fcecc

Comment by Ivan Fefer [ 21/Aug/23 ]

Okay, several good news:
1. I tried a lot of different ways to reproduce the potential issue and in most cases everything works correctly.

2. When it doesn't work, query fails instead of returning incorrect result.

3. The only way to make it fail is to use movePrimary, which is extremely rare in practice.

Still, this is something we would like to fix, as it can cause some problems in the future.

Comment by Ivan Fefer [ 18/Aug/23 ]

There is a jstest for this behaviour: https://github.com/mongodb/mongo/blob/master/jstests/sharding/snapshot_reads_target_at_point_in_time.js

 

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