summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2022-05-16 15:45:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-16 17:39:57 +0000
commitfeb2dfc188dd4108224c85ab03b0dd0d7ceaa8ea (patch)
tree16f7eea954582deb0666fc49b9ca9eaafde55bc1
parent5b39b570b4f4f4c4c0c054bb3e0b20f51d0312b6 (diff)
downloadmongo-feb2dfc188dd4108224c85ab03b0dd0d7ceaa8ea.tar.gz
SERVER-66031 rename must succeed on all shards when UUIDs provided for C2C
-rw-r--r--jstests/sharding/rename_sharded.js30
-rw-r--r--src/mongo/db/s/rename_collection_participant_service.cpp2
2 files changed, 29 insertions, 3 deletions
diff --git a/jstests/sharding/rename_sharded.js b/jstests/sharding/rename_sharded.js
index 87f98dee46b..c352ebf4f20 100644
--- a/jstests/sharding/rename_sharded.js
+++ b/jstests/sharding/rename_sharded.js
@@ -221,12 +221,12 @@ const mongos = st.s0;
assert.commandFailed(fromColl.renameCollection(toNs.split('.')[1], false /* dropTarget*/));
}
+const fcvDoc = testDB.adminCommand({getParameter: 1, featureCompatibilityVersion: 1});
// Rename to target collection with very a long name
{
const dbName = 'testRenameToCollectionWithVeryLongName';
const testDB = st.rs0.getPrimary().getDB(dbName);
- const fcvDoc = testDB.adminCommand({getParameter: 1, featureCompatibilityVersion: 1});
if (MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version, '5.3') >= 0) {
const longEnoughNs = dbName + '.' +
'x'.repeat(235 - dbName.length - 1);
@@ -237,4 +237,32 @@ const mongos = st.s0;
}
}
+// For C2C: rename of existing collection with correct uuid as argument must succeed
+// (Also creating target collection to test target UUID internal check)
+if (MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version, '6.0') >= 0) {
+ const dbName = 'testRenameToUnshardedCollectionWithSourceUUID';
+ const fromCollName = 'from';
+ const fromNs = dbName + '.' + fromCollName;
+ const toNs = dbName + '.to';
+ assert.commandWorked(
+ mongos.adminCommand({enablesharding: dbName, primaryShard: st.shard0.shardName}));
+ const fromColl = mongos.getCollection(fromNs);
+ fromColl.insert({a: 0});
+
+ const toColl = mongos.getCollection(toNs);
+ toColl.insert({b: 0});
+
+ const sourceUUID = assert.commandWorked(st.getDB(dbName).runCommand({listCollections: 1}))
+ .cursor.firstBatch.find(c => c.name === fromCollName)
+ .info.uuid;
+
+ // The command succeeds when the correct UUID is provided.
+ assert.commandWorked(mongos.adminCommand({
+ renameCollection: fromNs,
+ to: toNs,
+ dropTarget: true,
+ collectionUUID: sourceUUID,
+ }));
+}
+
st.stop();
diff --git a/src/mongo/db/s/rename_collection_participant_service.cpp b/src/mongo/db/s/rename_collection_participant_service.cpp
index bf2766e668d..e09cb196980 100644
--- a/src/mongo/db/s/rename_collection_participant_service.cpp
+++ b/src/mongo/db/s/rename_collection_participant_service.cpp
@@ -328,8 +328,6 @@ SemiFuture<void> RenameParticipantInstance::_runImpl(
RenameCollectionOptions options;
options.dropTarget = _doc.getDropTarget();
options.stayTemp = _doc.getStayTemp();
- options.expectedSourceUUID = _doc.getExpectedSourceUUID();
- options.expectedTargetUUID = _doc.getExpectedTargetUUID();
renameOrDropTarget(
opCtx, fromNss(), toNss(), options, _doc.getSourceUUID(), _doc.getTargetUUID());