blob: 5f00bc5e2a3604f2ddb697f15af6f2115cabafcd (
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
|
// Previously, the listCollections command would validate the views in all cases, potentially
// causing a secondary to crash in the initial sync of a replicate set in the case that invalid
// views were present. This test ensures that crashes no longer occur in those circumstances.
(function() {
'use strict';
const name = "initial_sync_invalid_views";
let replSet = new ReplSetTest({name: name, nodes: 1});
let oplogSizeOnPrimary = 1; // size in MB
replSet.startSet({oplogSize: oplogSizeOnPrimary});
replSet.initiate();
let primary = replSet.getPrimary();
let coll = primary.getDB('test').foo;
assert.commandWorked(coll.insert({a: 1}));
// Add a secondary node but make it hang before copying databases.
let secondary = replSet.add();
secondary.setSlaveOk();
assert.commandWorked(secondary.getDB('admin').runCommand(
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'}));
replSet.reInitiate();
assert.commandWorked(primary.getDB('test').system.views.insert({invalid: NumberLong(1000)}));
assert.commandWorked(secondary.getDB('admin').runCommand(
{configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'off'}));
replSet.awaitSecondaryNodes(200 * 1000);
// Skip collection validation during stopMongod if invalid views exists.
TestData.skipValidationOnInvalidViewDefinitions = true;
replSet.stopSet();
})();
|