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
|
'use strict';
/**
* update_eval.js
*
* Creates several docs. On each iteration, each thread chooses:
* - a random doc
* - whether to $set or $unset its field
* - what value to $set the field to
* and then applies the update using db.runCommand({ eval: ... })
*/
load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload
load('jstests/concurrency/fsm_workloads/update_simple.js'); // for $config
var $config = extendWorkload($config, function($config, $super) {
$config.data.doUpdate = function doUpdate(db, collName, query, updater) {
var evalResult = db.runCommand({
eval: function(f, collName, query, updater) {
return tojson(f(db, collName, query, updater));
},
args: [$super.data.doUpdate, collName, query, updater],
nolock: this.nolock
});
assertAlways.commandWorked(evalResult);
var res = JSON.parse(evalResult.retval);
return res;
};
$config.data.nolock = false;
return $config;
});
|