Rename MongoDB collection not working

1,541 views
Skip to first unread message

Vlad Shiligin

unread,
Dec 10, 2015, 9:46:00 AM12/10/15
to ReactiveMongo - http://reactivemongo.org
Hi
I have a bit of functionality in my project where a mongoDb collection is being renamed.
All was working OK until I have upgraded from 0.10.5 to version 0.11.5.
It does not flag any errors it just does not do anything.
Please advise.
Regards
Vlad

Vlad Shiligin

unread,
Dec 11, 2015, 8:03:43 AM12/11/15
to ReactiveMongo - http://reactivemongo.org
...after some investigation: 
1) according to MongoDB docs: "renameCollection may only be run against the admin database". Which means that the reactivemongo's collection.rename(...) will never work unless the user is auth'd. 
2) because this method returns Future[Unit] - there's no way to get hold on feedback messages returned by mongoDB.

Cédric Chantepie

unread,
Dec 12, 2015, 5:39:59 AM12/12/15
to ReactiveMongo - http://reactivemongo.org
Future is sufficient to hold error details.

Cédric Chantepie

unread,
Dec 12, 2015, 4:35:48 PM12/12/15
to ReactiveMongo - http://reactivemongo.org

James Brems

unread,
Oct 28, 2016, 4:41:03 AM10/28/16
to ReactiveMongo - http://reactivemongo.org
Hi,

I have a similar problem. I used CollectionMetaCommands.rename with 0.10.5 and it worked perfectly. Now I want to switch to 0.11.14 and the command does not work anymore. I do not get an error in application log, but I see the following error in mongo.log:

Unauthorized: renameCollection may only be run against the admin database

Is 0.11.14 more restrictive than 0.10.5 when it comes to "admin" commands? I never had an admin user and never needed to authorize with 0.10.5.

Br
James

Cédric Chantepie

unread,
Oct 28, 2016, 1:03:52 PM10/28/16
to ReactiveMongo - http://reactivemongo.org
Hi,

(2) is wrong, as Future.failed represents possible error as any other async op.

You could have a look at the documentation: http://reactivemongo.org/releases/0.12/documentation/release-details.html#administration

Jordan Messec

unread,
Nov 11, 2016, 3:08:46 PM11/11/16
to ReactiveMongo - http://reactivemongo.org
Agreed. It appears to be trying to reference the  
db.runCommand( { renameCollection: "test.orders", to: "test.orders2014" }
command when it should be referencing the 
 db.orders.renameCollection( "orders2014" )
command, as according to the MongoDB docs.
Reply all
Reply to author
Forward
0 new messages