1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
'use strict';
/**
* update_and_bulk_insert.js
*
* Each thread alternates between inserting 100 documents and updating every document in the
* collection.
*
* This workload was designed to test for an issue similar to SERVER-20512 with UpdateStage, where
* we attempted to make a copy of a record after a WriteConflictException occurred in
* Collection::updateDocument().
*/
var $config = (function() {
var states = {
insert: function insert(db, collName) {
var bulk = db[collName].initializeUnorderedBulkOp();
for (var i = 0; i < 10; ++i) {
bulk.insert({});
}
assert.commandWorked(bulk.execute());
},
update: function update(db, collName) {
var res = db[collName].update({}, {$inc: {n: 1}}, {multi: true});
assertAlways.lte(0, res.nMatched, tojson(res));
assertAlways.eq(res.nMatched, res.nModified, tojson(res));
assertAlways.eq(0, res.nUpserted, tojson(res));
}
};
var transitions = {insert: {insert: 0.2, update: 0.8}, update: {insert: 0.2, update: 0.8}};
return {
threadCount: 5,
iterations: 30,
startState: 'insert',
states: states,
transitions: transitions
};
})();
|