[SERVER-21948] DuplicateKeyError during upsert Created: 18/Dec/15  Updated: 18/Dec/15  Resolved: 18/Dec/15

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 3.0.8
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Mateusz Moneta Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14322 Retry on predicate unique index viola... Closed
Operating System: ALL
Participants:

 Description   

Hi,

this error is very rare (I cannot reproduce it), it happens on production every one-two hours (operation which cause this errors have rate ~100/s).

I read about this issue but every topic I found is about multiple unique indexes which isn't the case here.

My collection has one unique index (_id), two regular ones and one Map Field(EmbededDocumentField).

I think these issues started after upgrading Mongo to 3.0 and WiredTiger engine.

Current setup:
MongoDB 3.0.8
PyMongo 3.2.0

Sample query which causing issue:

collection.update({'_id': '9737600500733084563'}, {'$inc': {'fields.123.counters.33' : 1}}, upsert=True)



 Comments   
Comment by Kaloian Manassiev [ 18/Dec/15 ]

Hi Mateusz,

This is duplicate of SERVER-14322 and as of now the error is expected. Please see the mongodb upsert documentation for more information on how to handle this. In particular, this part:

If the operation fails because of a duplicate index key error, applications may retry the operation which will succeed as an update operation.

-Kal.

Generated at Thu Feb 08 03:58:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.