diff options
author | Jason Zhang <jason.zhang@mongodb.com> | 2019-07-25 13:33:16 -0400 |
---|---|---|
committer | Jason Zhang <jason.zhang@mongodb.com> | 2019-08-14 14:45:48 -0400 |
commit | e5e8082edcc4f41c7535e2129d39cf491b54ddea (patch) | |
tree | 392c2e16cbb7fa024092f0fd5c94eb5a12448e42 /src/mongo/db/catalog | |
parent | 866e3969c40539a0cf9c2f9033093ae19665f4c6 (diff) | |
download | mongo-e5e8082edcc4f41c7535e2129d39cf491b54ddea.tar.gz |
SERVER-42121 Make mongo's renameCollection call configsvrRenameCollection.
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r-- | src/mongo/db/catalog/rename_collection.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index f535fdc32e1..7ecac53240a 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -62,6 +62,9 @@ #include "mongo/util/scopeguard.h" namespace mongo { + +MONGO_FAIL_POINT_DEFINE(useRenameCollectionPathThroughConfigsvr); + namespace { MONGO_FAIL_POINT_DEFINE(writeConflictInRenameCollCopyToTmp); @@ -98,8 +101,11 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx, str::stream() << "Not primary while renaming collection " << source << " to " << target); - if (isCollectionSharded(opCtx, source)) - return {ErrorCodes::IllegalOperation, "source namespace cannot be sharded"}; + // TODO: SERVER-42638 Replace checks of cm() with cm()->distributionMode() == sharded + if (!MONGO_FAIL_POINT(useRenameCollectionPathThroughConfigsvr)) { + if (isCollectionSharded(opCtx, source)) + return {ErrorCodes::IllegalOperation, "source namespace cannot be sharded"}; + } if (isReplicatedChanged(opCtx, source, target)) return {ErrorCodes::IllegalOperation, @@ -450,8 +456,11 @@ Status renameBetweenDBs(OperationContext* opCtx, return Status(ErrorCodes::NamespaceNotFound, "source namespace does not exist"); } - if (isCollectionSharded(opCtx, source)) - return {ErrorCodes::IllegalOperation, "source namespace cannot be sharded"}; + // TODO: SERVER-42638 Replace checks of cm() with cm()->distributionMode() == sharded + if (!MONGO_FAIL_POINT(useRenameCollectionPathThroughConfigsvr)) { + if (isCollectionSharded(opCtx, source)) + return {ErrorCodes::IllegalOperation, "source namespace cannot be sharded"}; + } if (isReplicatedChanged(opCtx, source, target)) return {ErrorCodes::IllegalOperation, |