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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/**
* Tests that an index build is resumable only once across restarts. If the resumed index build
* fails to run to completion before shutdown, it will restart from the beginning on the next server
* startup.
*
* @tags: [
* requires_majority_read_concern,
* requires_persistence,
* requires_replication,
* ]
*/
(function() {
"use strict";
load("jstests/noPassthrough/libs/index_build.js");
load("jstests/libs/sbe_util.js"); // For checkSBEEnabled.
load("jstests/libs/columnstore_util.js"); // For setUpServerForColumnStoreIndexTest.
const dbName = "test";
const collName = jsTestName();
let rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
let primary = rst.getPrimary();
const columnstoreEnabled =
checkSBEEnabled(primary.getDB(dbName), ["featureFlagColumnstoreIndexes"], true) &&
setUpServerForColumnStoreIndexTest(primary.getDB(dbName));
ResumableIndexBuildTest.runResumeInterruptedByShutdown(
rst,
dbName,
collName + "_collscan_drain",
{a: 1}, // index key pattern
"resumable_index_build1", // index name
{name: "hangIndexBuildDuringCollectionScanPhaseBeforeInsertion", logIdWithBuildUUID: 20386},
"collection scan",
{a: 1}, // initial doc
[{a: 2}, {a: 3}],
[{a: 4}, {a: 5}]);
ResumableIndexBuildTest.runResumeInterruptedByShutdown(
rst,
dbName,
collName + "_bulkload_drain_multikey",
{a: 1}, // index key pattern
"resumable_index_build2", // index name
{name: "hangIndexBuildDuringBulkLoadPhase", logIdWithIndexName: 4924400},
"bulk load",
{a: [11, 22, 33]}, // initial doc
[{a: 77}, {a: 88}],
[{a: 99}, {a: 100}]);
if (columnstoreEnabled) {
ResumableIndexBuildTest.runResumeInterruptedByShutdown(
rst,
dbName,
collName + "_collscan_drain_column_store",
{"$**": "columnstore"}, // index key pattern
"resumable_index_build3", // index name
{name: "hangIndexBuildDuringCollectionScanPhaseBeforeInsertion", logIdWithBuildUUID: 20386},
"collection scan",
{a: 1}, // initial doc
(function(collection) {
assert.commandWorked(collection.insert([{a: [{b: 14}]}, {a: 15}]));
assert.commandWorked(collection.update({a: 1}, {a: 2}));
assert.commandWorked(collection.remove({"a.b": 14}));
assert.commandWorked(collection.insert({a: 1}));
assert.commandWorked(collection.remove({a: 2}));
assert.commandWorked(collection.update({a: 15}, {a: 2}));
}),
[{a: 16}, {a: 17}]);
ResumableIndexBuildTest.runResumeInterruptedByShutdown(
rst,
dbName,
collName + "_bulkload_drain_column_store",
{"$**": "columnstore"}, // index key pattern
"resumable_index_build4", // index name
{name: "hangIndexBuildDuringBulkLoadPhase", logIdWithIndexName: 4924400},
"bulk load",
{a: [44, 55, 66]}, // initial doc
(function(collection) {
assert.commandWorked(collection.insert([{a: [{b: 77}]}, {a: 88}]));
assert.commandWorked(collection.update({a: [44, 55, 66]}, {a: [55, 66]}));
assert.commandWorked(collection.remove({"a.b": 77}));
assert.commandWorked(collection.insert({a: 99}));
assert.commandWorked(collection.remove({a: [55, 66]}));
assert.commandWorked(collection.update({a: 99}, {a: 1}));
}),
[{a: 99}, {a: 100}]);
}
rst.stopSet();
})();
|