@@ -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