Dropping an index on 170M docs. How long will it block the DB ?

76 views
Skip to first unread message

Nicolas F

unread,
Oct 15, 2014, 12:29:59 PM10/15/14
to mongod...@googlegroups.com
Hi,

I have an index on two fields, with a high cardinality. I'd like to drop it, but I'm scared it would the block the db for minutes, even hours. http://docs.mongodb.org/manual/reference/command/dropIndexes/
For the record, creating this index on a new Replica Set member takes 1 hour.
I cannot block the database more than a few minutes.
The inbound traffic is 500 updates per second and I cannot stop it. I use Node.js clients, and as far as I know, they retry queries on failures. But I guess they won't retry for 2 hours :)

Thanks!

Nicolas F

unread,
Oct 15, 2014, 12:34:10 PM10/15/14
to mongod...@googlegroups.com
It's in the subject, but to be clear: the collection contains 170 million documents.

Rob Moore

unread,
Oct 15, 2014, 1:15:51 PM10/15/14
to mongod...@googlegroups.com

If that is the case I would use the same strategy to remove the index as is recommended for adding a new index to a replica set.

http://docs.mongodb.org/manual/tutorial/build-indexes-on-replica-sets/

Basically:

1) Stop a secondary and restart without the -replSet option and on a different port.
2) Remove the index using the shell by connecting directly to the new port.
3) Stop the member and restart as a member of the set (original port and with -replSet).

Repeat for all secondaries.

Step down the primary and repeat for the primary that is now secondary.

Rob.

Nicolas Fouché

unread,
Oct 15, 2014, 2:35:58 PM10/15/14
to mongod...@googlegroups.com
Nice trick. Thanks !
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/baWgqXM7-ww/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8a6e9504-dbe2-4f26-aa99-03787fe3e5cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas F

unread,
Oct 16, 2014, 5:57:01 AM10/16/14
to mongod...@googlegroups.com
Like you said, I dropped the index on each server after starting them out of the replicaset. It worked perfectly !
The dropIndex() command returned instantly, and nothing was written in the log. So I wonder if I could have just dropped the index on the full replicaset from the primary without any downtime.

Asya Kamsky

unread,
Oct 19, 2014, 11:24:27 PM10/19/14
to mongodb-user
Yes, you could have dropped the index without worrying about performance.

Not sure why you thought it might take a long time - unlike building
an index, it doesn't have to do much work.

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/6b823095-e428-448e-84a9-c63337365053%40googlegroups.com.

Nicolas Fouché

unread,
Oct 20, 2014, 11:22:52 AM10/20/14
to mongod...@googlegroups.com
That's what I assumed, until I saw this big red box on http://docs.mongodb.org/manual/reference/command/dropIndexes/ .

"Warning. This command obtains a write lock on the affected database and will block other operations until it has completed."

This sentence does not say it would take a long time to drop an index, but blocking the DB was a no-go for us, thus the question, to be 100% sure.

Nicolas
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages