mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-47522 Distinct command: Convert usage of getCollectionDescription_DEPRECATED to getCollectionDescription
This commit is contained in:
parent
75e46058ca
commit
ca7c12950c
@ -21,18 +21,14 @@ assert.commandWorked(coll.insert(testDoc, {writeConcern: {w: "majority"}}));
|
||||
assert.commandWorked(view.runCommand(
|
||||
"create", {viewOn: coll.getName(), pipeline: [], writeConcern: {w: "majority"}}));
|
||||
|
||||
const isMongos = assert.commandWorked(db.runCommand("ismaster")).msg === "isdbgrid";
|
||||
if (isMongos) {
|
||||
// Refresh the router's and shard's database versions so the distinct run below can succeed.
|
||||
// This is necessary because shards always abort their local transaction on stale version
|
||||
// errors and mongos is not allowed to retry on these errors in a transaction if the stale
|
||||
// shard has completed at least one earlier statement.
|
||||
assert.eq(view.distinct("_id"), ["kyle"]);
|
||||
}
|
||||
|
||||
// Run a dummy find to start the transaction.
|
||||
jsTestLog("Starting transaction.");
|
||||
session.startTransaction({readConcern: {level: "snapshot"}});
|
||||
// Refresh the router's and shard's database versions so the distinct run below can succeed.
|
||||
// This is necessary because shards always abort their local transaction on stale version
|
||||
// errors and mongos is not allowed to retry on these errors in a transaction if the stale
|
||||
// shard has completed at least one earlier statement.
|
||||
assert.eq(view.distinct("_id"), ["kyle"]);
|
||||
let cursor = coll.find();
|
||||
cursor.next();
|
||||
|
||||
|
@ -191,14 +191,13 @@ public:
|
||||
|
||||
// Distinct doesn't filter orphan documents so it is not allowed to run on sharded
|
||||
// collections in multi-document transactions.
|
||||
uassert(ErrorCodes::OperationNotSupportedInTransaction,
|
||||
"Cannot run 'distinct' on a sharded collection in a multi-document transaction. "
|
||||
"Please see http://dochub.mongodb.org/core/transaction-distinct for a recommended "
|
||||
"alternative.",
|
||||
!opCtx->inMultiDocumentTransaction() ||
|
||||
!CollectionShardingState::get(opCtx, nss)
|
||||
->getCollectionDescription_DEPRECATED()
|
||||
.isSharded());
|
||||
uassert(
|
||||
ErrorCodes::OperationNotSupportedInTransaction,
|
||||
"Cannot run 'distinct' on a sharded collection in a multi-document transaction. "
|
||||
"Please see http://dochub.mongodb.org/core/transaction-distinct for a recommended "
|
||||
"alternative.",
|
||||
!opCtx->inMultiDocumentTransaction() ||
|
||||
!CollectionShardingState::get(opCtx, nss)->getCollectionDescription().isSharded());
|
||||
|
||||
const ExtensionsCallbackReal extensionsCallback(opCtx, &nss);
|
||||
auto defaultCollation =
|
||||
|
Loading…
Reference in New Issue
Block a user