blob: d11264778941870700f0cdd32abefb22d6376ba9 (
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
|
/**
* Confirm that replica members undergoing initial sync fail if an invalid index specification is
* encountered (where index version is >= 2).
*/
(function() {
"use strict";
load("jstests/replsets/rslib.js");
const testName = "initial_sync_invalid_index_spec";
const replTest = new ReplSetTest({nodes: 1});
replTest.startSet();
replTest.initiate();
let primaryDB = replTest.getPrimary().getDB(testName);
// Create a V2 index with invalid spec field.
primaryDB.adminCommand(
{configureFailPoint: "skipIndexCreateFieldNameValidation", mode: "alwaysOn"});
assert.commandWorked(primaryDB.runCommand(
{createIndexes: "test", indexes: [{v: 2, name: "x_1", key: {x: 1}, invalidOption: 1}]}));
// Add another node to the replica set to allow an initial sync to occur.
var initSyncNode = replTest.add();
var initSyncNodeAdminDB = initSyncNode.getDB("admin");
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(replTest);
const msgInvalidOption = "The field 'invalidOption' is not valid for an index specification";
const msgInitialSyncFatalAssertion = "Fatal assertion 40088 InitialSyncFailure";
const assertFn = function() {
return rawMongoProgramOutput().match(msgInvalidOption) &&
rawMongoProgramOutput().match(msgInitialSyncFatalAssertion);
};
assert.soon(assertFn, "Initial sync should have aborted on invalid index specification");
assert.soon(function() {
try {
initSyncNodeAdminDB.runCommand({ping: 1});
} catch (e) {
return true;
}
return false;
}, "Node did not terminate due to invalid index spec during initial sync", 60 * 1000);
replTest.stop(initSyncNode, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
replTest.stopSet();
})();
|