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
|
// Verifies read/write concern defaults are loaded at startup by a mongos and non-sharded replica
// set node.
//
// This test restarts a replica set node, which requires persistence and journaling.
// @tags: [
// requires_persistence,
// requires_replication,
// requires_sharding,
// ]
(function() {
"use strict";
load("jstests/replsets/rslib.js"); // For reconnect.
function runTest(conn, failPointConn, restartFn) {
// Set a default rwc.
assert.commandWorked(
conn.adminCommand({setDefaultRWConcern: 1, defaultReadConcern: {level: "local"}}));
let res = assert.commandWorked(conn.adminCommand({getDefaultRWConcern: 1}));
assert.eq(res.defaultReadConcern, {level: "local"});
// Restart the node with disabled rwc refreshes.
restartFn();
reconnect(conn);
reconnect(failPointConn);
// Verify the server attempted to load the defaults at startup.
checkLog.contains(conn, "Error loading read and write concern defaults at startup");
checkLog.contains(conn,
"Failing read/write concern persisted defaults lookup because of fail point");
// Disable the fail point and verify the defaults can be returned.
assert.commandWorked(
failPointConn.adminCommand({configureFailPoint: "failRWCDefaultsLookup", mode: "off"}));
res = assert.commandWorked(conn.adminCommand({getDefaultRWConcern: 1}));
assert.eq(res.defaultReadConcern, {level: "local"});
// Unset the default read concern so it won't interfere with testing hooks.
assert.commandWorked(conn.adminCommand({setDefaultRWConcern: 1, defaultReadConcern: {}}));
}
jsTestLog("Testing mongos...");
{
// Use 1 node CSRS so the failpoint to disable rwc lookup only needs to be set on one node.
const st = new ShardingTest({shards: 1, config: 1});
runTest(st.s, st.configRS.getPrimary(), () => {
assert.commandWorked(st.configRS.getPrimary().adminCommand(
{configureFailPoint: "failRWCDefaultsLookup", mode: "alwaysOn"}));
st.restartMongos(0);
});
st.stop();
}
jsTestLog("Testing plain replica set node...");
{
const rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
runTest(primary, primary, () => {
rst.restart(
primary,
{setParameter: "failpoint.failRWCDefaultsLookup=" + tojson({mode: "alwaysOn"})});
rst.getPrimary();
});
rst.stopSet();
}
})();
|