Revert "SERVER-120914 UnshardCollection now fails with NamespaceNotSharded for untracked collections (#49130)" (#49219)

Co-authored-by: auto-revert-processor <devprod-si-team@mongodb.com>
GitOrigin-RevId: c9a2e7dd02bb7055136848a0dbd7cdb9a262bfb7
This commit is contained in:
auto-revert-app[bot]
2026-03-06 23:47:07 +00:00
committed by MongoDB Bot
parent 8ceb6ed988
commit 6bc0d4cba2
3 changed files with 1 additions and 20 deletions

View File

@@ -149,8 +149,6 @@ last-continuous:
ticket: SERVER-112273
- test_file: jstests/replsets/retryable_write_interrupted_on_stepdown.js
ticket: SERVER-110728
- test_file: jstests/sharding/unshard_collection_basic.js
ticket: SERVER-120914
suites: null
last-lts:
all:
@@ -798,6 +796,4 @@ last-lts:
ticket: SERVER-112273
- test_file: jstests/replsets/retryable_write_interrupted_on_stepdown.js
ticket: SERVER-110728
- test_file: jstests/sharding/unshard_collection_basic.js
ticket: SERVER-120914
suites: null

View File

@@ -49,7 +49,7 @@ const unshardedCollName = "foo_unsharded";
const unshardedCollNS = dbName + "." + unshardedCollName;
assert.commandWorked(st.s.getDB(dbName).runCommand({create: unshardedCollName}));
let res = mongos.adminCommand({unshardCollection: unshardedCollNS});
assert.commandFailedWithCode(res, ErrorCodes.NamespaceNotSharded);
assert.commandFailedWithCode(res, [ErrorCodes.NamespaceNotFound, ErrorCodes.NamespaceNotSharded]);
jsTest.log("Verify unshardCollection succeeds with explicit toShard option");
let coll = mongos.getDB(dbName)[collName];

View File

@@ -149,21 +149,6 @@ ExecutorFuture<void> ReshardCollectionCoordinator::_runImpl(
Grid::get(opCtx)->catalogCache()->getCollectionPlacementInfoWithRefresh(opCtx,
nss()));
// For unshardCollection on untracked collections that exist locally, return
// NamespaceNotSharded. Non-existent collections fall through to NamespaceNotFound
// below. Tracked-unsplittable collections are handled downstream for idempotency.
if (resharding::isUnshardCollection(_doc.getProvenance()) && !cmOld.hasRoutingTable()) {
auto coll = acquireCollectionMaybeLockFree(
opCtx,
CollectionAcquisitionRequest::fromOpCtx(
opCtx, nss(), AcquisitionPrerequisites::kRead));
if (coll.exists()) {
uasserted(ErrorCodes::NamespaceNotSharded,
str::stream() << "Collection '" << nss().toStringForErrorMsg()
<< "' is not sharded.");
}
}
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "Collection '" << nss().toStringForErrorMsg()
<< "' not found in cluster catalog",