dropping collections does NOT work - drop() command just returns "false"

1,312 views
Skip to first unread message

Bob

unread,
Jan 31, 2011, 3:51:38 PM1/31/11
to mongodb-user
I have lots of temp map-reduce collections that I need to drop (about
9000). When I try to drop them, using following code as well as other
implementations of similar code, it always fails to most of the drop
collections. drop() command simply returns "false" and those
collections are not removed.

Collections are named such as: tmp.mr.mapreduce_1296506891_5211

I'm running MongoDB 1.6.3 on Windows.

var names = db.getCollectionNames();

for(var i = 0; i < names.length; i++) { if(names[i].indexOf("mr.") >
-1) { db[names[i]].drop();} }

After running above command, I still have more than 6000 temp map-
reduce collections, which I cannot seem to drop.

Eliot Horowitz

unread,
Jan 31, 2011, 4:11:18 PM1/31/11
to mongod...@googlegroups.com
Can you see if there are any errors on the server?

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

GVP

unread,
Jan 31, 2011, 6:21:36 PM1/31/11
to mongodb-user
@Bob;

Two questions:

1. Are you trying to do this on the slave or on the master?
2. Any idea why you have all of the temp MRs?
They're supposed to disappear when the connection closes, could
this be a bug?

Aaron Bickell

unread,
Feb 1, 2011, 9:12:26 AM2/1/11
to mongodb-user

I had the very same issue, and in fact eventually ran Mongo out of
values in the namespace. Two options that may work are 1)
periodically cycling the client process that is running the Map/
Reduces or 2) explicitly drop the temp collection in code after you
are done reading out of it. I think temp collections are going away
in a future version, but this technique is getting us by today. Good
luck.

Aaron
Reply all
Reply to author
Forward
0 new messages