[SERVER-60860] ReshardingCollectionCloner uses primary read preference when nearest was intended Created: 20/Oct/21  Updated: 29/Oct/23  Resolved: 29/Nov/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 5.0.0, 5.1.0-rc0
Fix Version/s: 5.2.0, 5.1.2, 5.0.6

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Brett Nawrocki
Resolution: Fixed Votes: 0
Labels: PM-234, sharding-nyc-subteam1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
causes SERVER-61945 Resharding collection cloning may fai... Closed
Related
is related to SERVER-57686 We need test coverage that runs resha... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.1, v5.0
Sprint: Sharding 2021-11-29, Sharding 2021-12-13
Participants:
Story Points: 2

 Description   

sharded_agg_helpers::dispatchShardPipeline() uses the read preference set on the OperationContext already and therefore ignores the read preference on the AggregateCommandRequest that's passed into sharded_agg_helpers::targetShardsAndAddMergeCursors() by ReshardingCollectionCloner.

Acceptance criteria: Run reshard_collection_cloner.js and manually verify the profiler entry for the aggregate command can be found on a secondary. If possible, also verify the $readPreference for the aggregate was sent with nearest



 Comments   
Comment by Githook User [ 02/Dec/21 ]

Author:

{'name': 'Brett Nawrocki', 'email': 'brett.nawrocki@mongodb.com', 'username': 'brettnawrocki'}

Message: SERVER-60860 Resharding cloner now really uses read preference Nearest

ReshardingCollectionCloner::_targetAggregationRequest() previously
specified its intended read preference of Nearest on the
AggregateCommandRequest it passes to
sharded_agg_helpers::targetShardsAndAddMergeCursors(). However, when
sharded_agg_helpers::dispatchShardPipeline() is eventually called, this
function ignores the read preference in the command in favor of the read
preference set on the pipeline's expression context's operation context.
As a result, _targetAggregationRequest() now additionally sets its read
preference on the pipeline's opCtx.

(cherry picked from commit cb03a2eb88f90d7ec32dc49fc836c075eb1d44b9)
Branch: v5.1
https://github.com/mongodb/mongo/commit/0eb469288e56194f30f77db5fce9db34b2397d37

Comment by Githook User [ 02/Dec/21 ]

Author:

{'name': 'Brett Nawrocki', 'email': 'brett.nawrocki@mongodb.com', 'username': 'brettnawrocki'}

Message: SERVER-60860 Resharding cloner now really uses read preference Nearest

ReshardingCollectionCloner::_targetAggregationRequest() previously
specified its intended read preference of Nearest on the
AggregateCommandRequest it passes to
sharded_agg_helpers::targetShardsAndAddMergeCursors(). However, when
sharded_agg_helpers::dispatchShardPipeline() is eventually called, this
function ignores the read preference in the command in favor of the read
preference set on the pipeline's expression context's operation context.
As a result, _targetAggregationRequest() now additionally sets its read
preference on the pipeline's opCtx.

(cherry picked from commit cb03a2eb88f90d7ec32dc49fc836c075eb1d44b9)
Branch: v5.0
https://github.com/mongodb/mongo/commit/1d075ebc73e0ea1299f5d6cbe9a4a6a3144d6835

Comment by Githook User [ 29/Nov/21 ]

Author:

{'name': 'Brett Nawrocki', 'email': 'brett.nawrocki@mongodb.com', 'username': 'brettnawrocki'}

Message: SERVER-60860 Resharding cloner now really uses read preference Nearest

ReshardingCollectionCloner::_targetAggregationRequest() previously
specified its intended read preference of Nearest on the
AggregateCommandRequest it passes to
sharded_agg_helpers::targetShardsAndAddMergeCursors(). However, when
sharded_agg_helpers::dispatchShardPipeline() is eventually called, this
function ignores the read preference in the command in favor of the read
preference set on the pipeline's expression context's operation context.
As a result, _targetAggregationRequest() now additionally sets its read
preference on the pipeline's opCtx.
Branch: master
https://github.com/mongodb/mongo/commit/cb03a2eb88f90d7ec32dc49fc836c075eb1d44b9

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