Skip to content

Commit 1b446a6

Browse files
pierlauroMongoDB Bot
authored andcommitted
SERVER-109087 Add system.buckets. to tmp buckets collection name (#39954)
GitOrigin-RevId: 201294554725900620b34c3e870fab7ddc260d29
1 parent 3f522bb commit 1b446a6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/mongo/db/catalog/rename_collection.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,14 @@ acquireLocksForRenameCollectionWithinDBForApplyOps(OperationContext* opCtx,
449449

450450
boost::optional<NamespaceString> nsForRenameOutOfTheWay;
451451
if (needsRenameOutOfTheWay) {
452-
auto tmpNameResult = makeUniqueCollectionName(opCtx, target.dbName(), "tmp%%%%%.rename");
452+
auto tmpNameResult = [&]() {
453+
std::string collectionNameModel = "tmp%%%%%.renameCollection";
454+
if (source.isTimeseriesBucketsCollection()) {
455+
collectionNameModel =
456+
NamespaceString::kTimeseriesBucketsCollectionPrefix + collectionNameModel;
457+
}
458+
return makeUniqueCollectionName(opCtx, target.dbName(), collectionNameModel);
459+
}();
453460
if (!tmpNameResult.isOK()) {
454461
return tmpNameResult.getStatus().withContext(
455462
getCanNotCreateTemporaryCollectionErrorMsg());
@@ -729,8 +736,14 @@ Status renameCollectionAcrossDatabases(OperationContext* opCtx,
729736

730737
// Note that this temporary collection name is used by MongoMirror and thus must not be changed
731738
// without consultation.
732-
auto tmpNameResult =
733-
makeUniqueCollectionName(opCtx, target.dbName(), "tmp%%%%%.renameCollection");
739+
auto tmpNameResult = [&]() {
740+
std::string collectionNameModel = "tmp%%%%%.renameCollection";
741+
if (source.isTimeseriesBucketsCollection()) {
742+
collectionNameModel =
743+
NamespaceString::kTimeseriesBucketsCollectionPrefix + collectionNameModel;
744+
}
745+
return makeUniqueCollectionName(opCtx, target.dbName(), collectionNameModel);
746+
}();
734747
if (!tmpNameResult.isOK()) {
735748
return tmpNameResult.getStatus().withContext(
736749
str::stream() << "Cannot generate temporary collection name to rename "

0 commit comments

Comments
 (0)