how can we fix DuplicateKey: E11000 duplicate key error index

636 views
Skip to first unread message

Robbie Cheng

unread,
Dec 27, 2012, 1:40:47 PM12/27/12
to mongod...@googlegroups.com
For some reasons, we have to generate ObjectId from the client, but we bumped into the above exception when we save our records into db.

1. any suggestion we can avoid this error.
2. does simple try-and-catch, assigning a new ObjectId, and retry fix the issue?
3. does solution #2 applied to massive save, too?

Thanks,
Robbie

Robbie Cheng

unread,
Dec 27, 2012, 1:42:48 PM12/27/12
to mongod...@googlegroups.com
btw, we're using mongodb 2.2. and java-driver is 2.9.1.

thanks,

Robbie Cheng於 2012年12月28日星期五UTC+8上午2時40分47秒寫道:

Sam Millman

unread,
Dec 27, 2012, 3:51:34 PM12/27/12
to mongod...@googlegroups.com
And you are sure you are getting this on new objects? What driver is this? The ObjectId that gets generated should stand a very very high chance of being unique. In fact  using PHP I haven't yet had a collision.


--
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
See also the IRC channel -- freenode.net#mongodb

Sam Millman

unread,
Dec 27, 2012, 3:51:56 PM12/27/12
to mongod...@googlegroups.com
Oops to add to that, what's your set-up?

Robbie Cheng

unread,
Dec 27, 2012, 7:11:17 PM12/27/12
to mongod...@googlegroups.com
We are running in a shared env with both journaling and replication set being enabled. Can't be 100% sure, but the issue seems shows up when we turns our sharded evn into replication set.

But we had a tricky party that the config servers is not aware of its shard is a relocation set instead of a single shard server. Not sure if it's related.

Thanks,

從我的 iPhone 傳送

Jeff Yemin

unread,
Jan 4, 2013, 9:33:18 PM1/4/13
to mongod...@googlegroups.com
Robbie,

Please upgrade to 2.9.3 or 2.10.1 of the Java driver. There is a
pretty nasty bug in 2.9.1 that is fixed in later versions.


Jeff

Robbie Cheng

unread,
Jan 4, 2013, 11:04:01 PM1/4/13
to mongod...@googlegroups.com, mongod...@googlegroups.com
Thanks!

從我的 iPhone 傳送
Reply all
Reply to author
Forward
0 new messages