[SERVER-59585] ReshardingOpObserver performs an invalid CollectionShardingRuntime cast on config servers Created: 25/Aug/21  Updated: 29/Oct/23  Resolved: 23/Sep/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 5.0.4, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Brett Nawrocki
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Sharding 2021-09-20, Sharding 2021-10-04
Participants:
Linked BF Score: 163
Story Points: 1

 Description   

ReshardingOpObserver is enabled on both --configsvrs and --shardsvrs. However, config servers use CollectionShardingStateStandalone rather than CollectionShardingRuntime and means calling CollectionShardingRuntime::get() on a config server is incorrect.

69
void assertCanExtractShardKeyFromDocs(OperationContext* opCtx,
70
                                      const NamespaceString& nss,
71
                                      std::vector<InsertStatement>::const_iterator begin,
72
                                      std::vector<InsertStatement>::const_iterator end) {
73
    const auto metadata = CollectionShardingRuntime::get(opCtx, nss)->getCurrentMetadataIfKnown();
74
    // A user can manually create a 'db.system.resharding.' collection that isn't guaranteed to be
75
    // sharded outside of running reshardCollection.
76
    uassert(ErrorCodes::NamespaceNotSharded,
77
            str::stream() << "Temporary resharding collection " << nss.toString()
78
                          << " is not sharded",
79
            metadata && metadata->isSharded());
80
 
81
    ...
82
}

https://github.com/mongodb/mongo/blob/7d58a3a7d1f1a8766c6f289f21ebd977385c4252/src/mongo/db/s/resharding/resharding_op_observer.cpp#L73



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 27/Sep/21 ]

Author:

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

Message: SERVER-59585 Fix invalid cast on config servers

ReshardingOpObserver is enabled on both --configsvrs and --shardsvrs.
However, config servers use CollectionShardingStateStandalone rather
than CollectionShardingRuntime and means calling
CollectionShardingRuntime::get() on a config server is incorrect.
Instead, use CollectionShardingState::get() to retrieve the information
without a cast.

Also, update test_resharding_test_fixture_detects_unowned_docs.js to
specify a shard version when performing its insert so that the
collection is considered to be sharded by the ReshardingOpObserver when
using the CollectionShardingState interface.

(cherry picked from commit bb887cdeca1bbb61b8a4b39139470b5cd18444d0)
Branch: v5.0
https://github.com/mongodb/mongo/commit/c33f0469c8ccee5fbffbfdff1c1ab61928e21ce1

Comment by Githook User [ 22/Sep/21 ]

Author:

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

Message: SERVER-59585 Fix invalid cast on config servers

ReshardingOpObserver is enabled on both --configsvrs and --shardsvrs.
However, config servers use CollectionShardingStateStandalone rather
than CollectionShardingRuntime and means calling
CollectionShardingRuntime::get() on a config server is incorrect.
Instead, use CollectionShardingState::get() to retrieve the information
without a cast.

Also, update test_resharding_test_fixture_detects_unowned_docs.js to
specify a shard version when performing its insert so that the
collection is considered to be sharded by the ReshardingOpObserver when
using the CollectionShardingState interface.
Branch: master
https://github.com/mongodb/mongo/commit/bb887cdeca1bbb61b8a4b39139470b5cd18444d0

Comment by Githook User [ 16/Sep/21 ]

Author:

{'name': 'Uladzimir Makouski', 'email': 'uladzimir.makouski@mongodb.com', 'username': 'umakouski'}

Message: Revert "SERVER-59585 Fix invalid cast on config servers"

This reverts commit 7375f66262489f5e93c9342ea57cf974b8a87a9b.
Branch: master
https://github.com/mongodb/mongo/commit/a5f28efa4e148a99a7b271aed0e5143c4a092614

Comment by Githook User [ 15/Sep/21 ]

Author:

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

Message: SERVER-59585 Fix invalid cast on config servers

ReshardingOpObserver is enabled on both --configsvrs and --shardsvrs.
However, config servers use CollectionShardingStateStandalone rather
than CollectionShardingRuntime and means calling
CollectionShardingRuntime::get() on a config server is incorrect.
Instead, use CollectionShardingState::get() to retrieve the information
without a cast.

Also, update test_resharding_test_fixture_detects_unowned_docs.js to
specify a shard version when performing its insert so that the
collection is considered to be sharded by the ReshardingOpObserver when
using the CollectionShardingState interface.
Branch: master
https://github.com/mongodb/mongo/commit/7375f66262489f5e93c9342ea57cf974b8a87a9b

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