From 6bc0d4cba2456e4e54e14fc32d2dd2092b8218ba Mon Sep 17 00:00:00 2001 From: "auto-revert-app[bot]" <166078896+auto-revert-app[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:47:07 +0000 Subject: [PATCH] Revert "SERVER-120914 UnshardCollection now fails with NamespaceNotSharded for untracked collections (#49130)" (#49219) Co-authored-by: auto-revert-processor GitOrigin-RevId: c9a2e7dd02bb7055136848a0dbd7cdb9a262bfb7 --- etc/backports_required_for_multiversion_tests.yml | 4 ---- jstests/sharding/unshard_collection_basic.js | 2 +- .../resharding/reshard_collection_coordinator.cpp | 15 --------------- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/etc/backports_required_for_multiversion_tests.yml b/etc/backports_required_for_multiversion_tests.yml index 5d665c18578..6d693dc0df5 100644 --- a/etc/backports_required_for_multiversion_tests.yml +++ b/etc/backports_required_for_multiversion_tests.yml @@ -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 diff --git a/jstests/sharding/unshard_collection_basic.js b/jstests/sharding/unshard_collection_basic.js index fe60ef199e0..86f24a0e43d 100644 --- a/jstests/sharding/unshard_collection_basic.js +++ b/jstests/sharding/unshard_collection_basic.js @@ -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]; diff --git a/src/mongo/db/s/resharding/reshard_collection_coordinator.cpp b/src/mongo/db/s/resharding/reshard_collection_coordinator.cpp index a1b554f53a5..0e88df89c7b 100644 --- a/src/mongo/db/s/resharding/reshard_collection_coordinator.cpp +++ b/src/mongo/db/s/resharding/reshard_collection_coordinator.cpp @@ -149,21 +149,6 @@ ExecutorFuture 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",