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
|
/**
* Tests that resumable index build state is written to disk upon clean shutdown when an index
* build is in the drain writes phase on a primary, and that the index build is subsequently
* completed when the node is started back up.
*
* @tags: [
* requires_majority_read_concern,
* requires_persistence,
* requires_replication,
* ]
*/
(function() {
"use strict";
load("jstests/noPassthrough/libs/index_build.js");
const dbName = "test";
const collName = jsTestName();
const rst = new ReplSetTest({nodes: 2});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
const coll = primary.getDB(dbName).getCollection(collName);
assert.commandWorked(coll.insert({a: 1}));
jsTestLog("Testing when primary shuts down in the middle of the first drain");
ResumableIndexBuildTest.run(
rst,
dbName,
collName,
[[{a: 1}]],
[{name: "hangIndexBuildDuringDrainWritesPhase", logIdWithIndexName: 4841800}],
0,
["drain writes"],
[{skippedPhaseLogID: 20392}],
[{a: 2}, {a: 3}],
[{a: 4}, {a: 5}]);
ResumableIndexBuildTest.run(
rst,
dbName,
collName,
[[{a: 1}]],
[{name: "hangIndexBuildDuringDrainWritesPhase", logIdWithIndexName: 4841800}],
1,
["drain writes"],
[{skippedPhaseLogID: 20392}],
[{a: 6}, {a: 7}],
[{a: 8}, {a: 9}]);
jsTestLog("Testing when primary shuts down after voting, but before commit quorum satisfied");
ResumableIndexBuildTest.runOnPrimaryToTestCommitQuorum(
rst,
dbName,
collName,
{a: 1},
"hangIndexBuildAfterSignalPrimaryForCommitReadiness",
"hangAfterIndexBuildFirstDrain",
[{a: 10}, {a: 11}],
[{a: 12}, {a: 13}]);
jsTestLog(
"Testing when primary shuts down after commit quorum satisfied, but before commitIndexBuild oplog entry written");
ResumableIndexBuildTest.runOnPrimaryToTestCommitQuorum(
rst,
dbName,
collName,
{a: 1},
"hangIndexBuildAfterSignalPrimaryForCommitReadiness",
"hangIndexBuildAfterSignalPrimaryForCommitReadiness",
[{a: 14}, {a: 15}],
[{a: 16}, {a: 17}]);
rst.stopSet();
})();
|