-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: 3.0.0, 3.2.0, 3.2.1
-
Component/s: Write Ops
-
None
-
ALL
-
We're getting a duplicate key error exception in a situation where one should never be occurring. It occurs infrequently, but consistently.
Our collection has a unique key defined on a combination of fields. We then performa `replaceOne()` with `upsert(true)`. Generally this works fine, but a tiny percentage of the writes result in an error being thrown by mongo stating:
`com.mongodb.MongoWriteException: E11000 duplicate key error index`
Our mongo instance is a single installation with no clustering and using the latest driver / server- 3.2.1.
Our client is using the default connection pool and is sending a hundreds of requests per second to the database. That said, our requests are unique in each is writing a different record to the database each time. It's not the case where we'd be sending a record with the same complex key via multiple threads at the same time.
It's worth noting that when this error occurs and an attempt made to re-upsert the exact same record record, it has succeeded every time.
We're using the Java driver, but research has shown other people have run into this same error on StackOverflow:
http://stackoverflow.com/questions/29305405/mongodb-impossible-e11000-duplicate-key-error-dup-key-when-upserting
- duplicates
-
SERVER-14322 Retry on predicate unique index violations of update + upsert -> insert when possible
- Closed