-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Concurrency, Storage
-
None
There is some confusion about upsert behaviour and its atomicity.
Given the following write :
db.col.update({a:1, b:1}, {$inc: {c:1}}, true)
The expectation is that there should never be more than one document in the database with
{a:1, b:1}in the collection. Now recently this line was added to the "Warning To avoid inserting the same document more than once, only use upsert: true if the query field is uniquely indexed.". This seems to apply that without such a unique index this behaviour is no longer guaranteed.
Questions :
1) Is this unique index needed and if so why (isn't this atomicity guaranteed by the write lock?)
2) Is the current behaviour different from earlier versions and if so, when has this changed.
- related to
-
SERVER-10350 Atomicity of Upserts on multi field unique index
- Closed