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
|
/**
* Ensure that a 6.0 version replicating a dbCheck oplog entry with the removed snapshotRead:false
* option does not crash when a 'latest' version receives the entry.
*
* @tags: [
* requires_replication,
* ]
*/
(function() {
"use strict";
load('jstests/multiVersion/libs/multi_rs.js');
const nodes = {
// We want the 6.0 node to be the primary.
n1: {binVersion: "6.0", rsConfig: {priority: 1}},
n2: {binVersion: "latest", rsConfig: {priority: 0}},
};
const rst = new ReplSetTest({nodes: nodes});
rst.startSet();
rst.initiate();
const dbName = "test";
const collName = jsTestName();
const primary = rst.getPrimary();
const primaryDB = primary.getDB(dbName);
const coll = primaryDB[collName];
assert.commandWorked(coll.insert({a: 1}));
// The 6.0 node will replicate the dbCheck oplog entry with the 'snapshotRead:false' option. This is
// not supported in recent versions and should be ignored, but not cause the node to crash.
assert.commandWorked(primaryDB.runCommand({"dbCheck": 1, snapshotRead: false}));
rst.awaitReplication();
function dbCheckCompleted(db) {
return db.currentOp().inprog.filter(x => x["desc"] == "dbCheck")[0] === undefined;
}
function forEachNode(f) {
f(rst.getPrimary());
f(rst.getSecondary());
}
function awaitDbCheckCompletion(db) {
assert.soon(() => dbCheckCompleted(db), "dbCheck timed out");
rst.awaitSecondaryNodes();
rst.awaitReplication();
forEachNode(function(node) {
const healthlog = node.getDB('local').system.healthlog;
assert.soon(function() {
return (healthlog.find({"operation": "dbCheckStop"}).itcount() == 1);
}, "dbCheck command didn't complete");
});
}
awaitDbCheckCompletion(primaryDB);
{
// The 6.0 primary should not report any errors.
const healthlog = primary.getDB('local').system.healthlog;
assert.eq(0, healthlog.find({severity: "error"}).itcount());
assert.eq(0, healthlog.find({severity: "warning"}).itcount());
}
{
// The latest secondary should log an error in the health log.
const secondary = rst.getSecondary();
const healthlog = secondary.getDB('local').system.healthlog;
assert.eq(1, healthlog.find({severity: "error"}).itcount());
assert.eq(0, healthlog.find({severity: "warning"}).itcount());
const errorEntry = healthlog.findOne({severity: "error"});
assert(errorEntry.hasOwnProperty('data'), tojson(errorEntry));
assert.eq(false, errorEntry.data.success, tojson(errorEntry));
assert(errorEntry.data.error.startsWith("Location6769502"), tojson(errorEntry));
}
rst.stopSet();
})();
|