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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/**
* Verify that the LatchAnalyzer is working to expectations
*
* @tags: [multiversion_incompatible, no_selinux, requires_latch_analyzer]
*/
(function() {
"use strict";
const failPointName = "enableLatchAnalysis";
function getLatchAnalysis() {
let serverStatus = assert.commandWorked(db.serverStatus({latchAnalysis: 1}));
return serverStatus.latchAnalysis;
}
function verifyField(fieldValue) {
// Every field in the latchAnalysis object is an integer that is greater than zero
// This function is meant to verify those conditions
assert.neq(fieldValue, null);
assert(typeof fieldValue == 'number');
assert(fieldValue >= 0);
}
function verifyLatchAnalysis({analysis, shouldHaveHierarchy}) {
assert(analysis);
if (shouldHaveHierarchy) {
jsTestLog("Failpoint is on; latch analysis: " + tojson(analysis));
} else {
jsTestLog("Failpoint is off; should be only basic stats: " + tojson(analysis));
}
for (var key in analysis) {
let singleLatch = analysis[key];
verifyField(singleLatch.created);
verifyField(singleLatch.destroyed);
verifyField(singleLatch.acquired);
verifyField(singleLatch.released);
verifyField(singleLatch.contended);
const acquiredAfter = singleLatch.acquiredAfter;
const releasedBefore = singleLatch.releasedBefore;
if (!shouldHaveHierarchy) {
assert(!acquiredAfter);
assert(!releasedBefore);
continue;
}
for (var otherKey in acquiredAfter) {
verifyField(acquiredAfter[otherKey]);
}
for (var otherKey in releasedBefore) {
verifyField(releasedBefore[otherKey]);
}
}
}
try {
{
let analysis = getLatchAnalysis();
verifyLatchAnalysis({analysis: analysis, shouldHaveHierarchy: false});
}
assert.commandWorked(db.adminCommand({
configureFailPoint: failPointName,
mode: "alwaysOn",
}));
{
let analysis = getLatchAnalysis();
verifyLatchAnalysis({analysis: analysis, shouldHaveHierarchy: true});
}
assert.commandWorked(db.adminCommand({
configureFailPoint: failPointName,
mode: "off",
}));
{
let analysis = getLatchAnalysis();
verifyLatchAnalysis({analysis: analysis, shouldHaveHierarchy: false});
}
} finally {
assert.commandWorked(db.adminCommand({
configureFailPoint: failPointName,
mode: "off",
}));
}
})();
|