| Steps To Reproduce: |
load('jstests/libs/parallelTester.js'); // for ScopedThread
|
|
var t = db.getSiblingDB("upsert_bug").getCollection("col");
|
|
t.drop();
|
|
var upsertFn = function() {
|
for (var i = 0; i < 100; ++i) {
|
var c = db.getSiblingDB("upsert_bug").getCollection("col");
|
var x = c.update({_id:3}, {$set: {a:'123', b: Math.random()}}, true)
|
assert(!x.getWriteError(), tojson(x));
|
c.remove({"_id":3});
|
}
|
}
|
|
var threads = [];
|
for (var i = 0; i < 2; ++i) {
|
var thread = new ScopedThread(upsertFn, db);
|
threads.push(thread);
|
thread.start();
|
}
|
|
threads.forEach(function(t) {
|
t.join();
|
});
|
Result:
./mongo < ~/tmp/upsert_bug.js
|
MongoDB shell version: 3.0.5
|
connecting to: test
|
true
|
true
|
connecting to: test
|
connecting to: test
|
assert failed : {
|
"nMatched" : 0,
|
"nUpserted" : 0,
|
"nModified" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: upsert_bug.col index: _id_ dup key: { : 3.0 }"
|
}
|
}
|
Error: assert failed : {
|
"nMatched" : 0,
|
"nUpserted" : 0,
|
"nModified" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: upsert_bug.col index: _id_ dup key: { : 3.0 }"
|
}
|
}
|
at Error (<anonymous>)
|
at doassert (src/mongo/shell/assert.js:11:14)
|
at assert (src/mongo/shell/assert.js:20:5)
|
at ____MongoToV8_newFunction_temp (<anonymous>:5:5)
|
2015-08-18T16:34:39.075-0700 I - js thread raised js exception: Error: assert failed : {
|
"nMatched" : 0,
|
"nUpserted" : 0,
|
"nModified" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: upsert_bug.col index: _id_ dup key: { : 3.0 }"
|
}
|
}
|
at Error (<anonymous>)
|
at doassert (src/mongo/shell/assert.js:11:14)
|
at assert (src/mongo/shell/assert.js:20:5)
|
at ____MongoToV8_newFunction_temp (<anonymous>:5:5) at src/mongo/shell/assert.js:13
|
bye
|
|
|
|