[SERVER-19600] Upsert results in E11000 duplicate key error Created: 27/Jul/15  Updated: 14/Aug/15  Resolved: 30/Jul/15

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

Type: Bug Priority: Major - P3
Reporter: Yury Michurin Assignee: Ramon Fernandez Marina
Resolution: Duplicate Votes: 0
Labels: concurrency
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 14.04 3.16.0-43 64bit, 16GB RAM, i5-4690 CPU @ 3.50GHz


Issue Links:
Duplicate
duplicates SERVER-14322 Retry on predicate unique index viola... Closed
is duplicated by SERVER-19920 Duplicate Key Error on Upsert with mu... Closed
Operating System: Linux
Steps To Reproduce:

https://github.com/yurynix/mongodb-upsert-test

Participants:

 Description   

I'm basically upserting documents that has random sid 1..100, and then update the hit counter on them.

So the document looks like that:

{ 'sid': 23, 'status': 'active' 'hit': 12 }

A timer changes the status field from 'active' to something else occasionally.

That program runs successfully on mongodb 3.0.4 with MMAPv1 engine, but throws E11000 errors with wiredtiger.

javascript code to replicate:
https://github.com/yurynix/mongodb-upsert-test

It's a reduced case of my more complicated python code (pymongo 3.0.3), which has the same problem.

expected result:
https://github.com/yurynix/mongodb-upsert-test/blob/master/expected.txt
(thats the result with the default engine)

actual result:
https://github.com/yurynix/mongodb-upsert-test/blob/master/actual.txt

Best regards,
Yury.



 Comments   
Comment by Ivan Fioravanti [ 11/Aug/15 ]

We are experiencing the same issue with C# client, I voted for SERVER-14322 right now. In the meantime we will revert to MMAPv1

Comment by Ramon Fernandez Marina [ 30/Jul/15 ]

Hi yurynix; you're right, this looks like a case of SERVER-14322. Unfortunately the only way to work around this issue at the moment is to retry the operation at the application level. It is possible that the issue is also present in MMAPv1, but it's much harder to trigger – WiredTiger provides much better concurrency, which is what makes this issue appear.

I'm going to close this ticket as a duplicate of SERVER-14322. Please feel free to vote for SERVER-14322 and watch it for further updates.

Regards,
Ramón.

Comment by Yury Michurin [ 27/Jul/15 ]

Ok, after further investigation, it looks like a duplicate of:
https://jira.mongodb.org/browse/SERVER-14322

I guess.
Still kind of weird that:
1. Upsert doesn't handle that for me and I should perform a retry in client code.
2. It only reproduces in wiredtiger for me.

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