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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
'use strict';
/**
* Run serverStatus() while running a large number of queries which are expected to reach maxTimeMS
* and time out.
*/
load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongos
var $config = (function() {
const states = {
/**
* This is a no-op, used only as a transition state.
*/
init: function init(db, collName) {},
/**
* Runs a query on the collection with a small enough batchSize to leave the cursor open.
* If the command was successful, stores the resulting cursor in 'this.cursor'.
*/
query: function query(db, collName) {
try {
// Set a low maxTimeMs and small batch size so that it's likely the cursor will
// time out over its lifetime.
let curs = db[collName]
.find({
$where: function() {
sleep(1);
return true;
}
})
.batchSize(2)
.maxTimeMS(10);
const c = curs.itcount();
} catch (e) {
assert.commandFailedWithCode(e, [
ErrorCodes.MaxTimeMSExpired,
]);
}
},
serverStatus: function serverStatus(db, collName) {
assert.commandWorked(db.adminCommand({serverStatus: 1}));
}
};
const transitions = {
init: {
query: 0.8,
serverStatus: 0.2,
},
query: {query: 0.8, serverStatus: 0.2},
serverStatus: {query: 0.5, serverStatus: 0.5},
};
function setup(db, collName, cluster) {
// Write some data.
assertWhenOwnColl.commandWorked(
db[collName].insert(Array.from({length: 100}, _ => ({a: 1}))));
}
return {
threadCount: 10,
iterations: 100,
states: states,
startState: 'init',
transitions: transitions,
setup: setup,
};
})();
|