blob: 2379bf1666843ec6c79f79d57931c85fc5060270 (
plain)
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
|
/*
* Test that replSetReconfig waits for a majority of nodes to replicate the config
* before starting another reconfig.
*
* @tags: [requires_fcv_44]
*/
(function() {
"use strict";
load("jstests/replsets/rslib.js");
load("jstests/libs/fail_point_util.js");
var replTest = new ReplSetTest({nodes: 2, useBridge: true});
replTest.startSet();
// Initiating with a high election timeout prevents unnecessary elections and also prevents
// the primary from stepping down if it cannot communicate with the secondary.
replTest.initiateWithHighElectionTimeout();
var primary = replTest.getPrimary();
var secondary = replTest.getSecondary();
// Disconnect the secondary from the primary.
secondary.disconnect(primary);
// Configure a failpoint so that we bypass the config quorum check and go straight to the
// config replication check.
let reconfigFailPoint = configureFailPoint(primary, "omitConfigQuorumCheck");
// Run a reconfig with a timeout of 5 seconds, this should fail with a maxTimeMSExpired error.
var config = primary.getDB("local").system.replset.findOne();
config.version++;
assert.commandFailedWithCode(
primary.getDB("admin").runCommand({replSetReconfig: config, maxTimeMS: 5000}),
ErrorCodes.MaxTimeMSExpired);
assert.eq(isConfigCommitted(primary), false);
// Try to run another reconfig, which should also time out because the previous config is
// not committed.
var config = primary.getDB("local").system.replset.findOne();
config.version++;
assert.commandFailedWithCode(
primary.getDB("admin").runCommand({replSetReconfig: config, maxTimeMS: 5000}),
ErrorCodes.CurrentConfigNotCommittedYet);
assert.eq(isConfigCommitted(primary), false);
// Reconnect the secondary to the primary.
secondary.reconnect(primary);
// Reconfig should now succeed.
config.version++;
assert.commandWorked(primary.getDB("admin").runCommand({replSetReconfig: config}));
assert(isConfigCommitted(primary));
reconfigFailPoint.off();
replTest.stopSet();
}());
|