suppressing duplicate key error so we can use mongo to lock across VMs

72 views
Skip to first unread message

Erez

unread,
Nov 23, 2014, 1:36:41 PM11/23/14
to mongod...@googlegroups.com
Hello,

We're trying to use MongoDB as a global lock across multiple VMs.  We've created a lock collection with a unique index on the type of lock, and we lock by trying to insert a record with a certain lock type value.  If there's a duplicate exception, we know it's already locked.  Otherwise, we know we're locked.

The problem now that we upgraded to 2.6.5 from 2.4 is that mongo sees the duplicate key exception as a user error and is logging it into our log files and counting it internally as a user error.  So, our monitoring software keeps flagging this as an exception, whereas it's really the way the system was designed to run.

Any ideas how to suppress this behavior?  Is there a way to configure the E11000 to be considered a normal use-case and not a user-exception?  Maybe on a database or collection level?  If not, is there another way to accomplish what we're trying to do without angering our monitoring software?

Thanks!

Asya Kamsky

unread,
Nov 24, 2014, 5:32:03 AM11/24/14
to mongodb-user
There isn't a setting that can be tweaked as far as I know to not count this as user assertion - but you are correct, that there are definitely use cases where unique indexes are created specifically to keep duplicates from being inserted and to let application know that this is a duplicate more efficiently than some other way.

It might make sense to open a jira ticket asking to correct this - since this particular "error" is not even logged till logLevel:1 it makes sense not to count it as user assertion...

Asya
P.S. you can always make the fix in your code and recompile... 


--
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/ebc545e2-c718-4a7d-8065-9b5a5969f854%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Erez Lirov

unread,
Nov 24, 2014, 11:13:34 AM11/24/14
to mongod...@googlegroups.com
Thanks!  Opened JIRA SERVER-16295

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/dSuyPsPH1ko/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.
Reply all
Reply to author
Forward
0 new messages