summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/resumable_index_build_bulk_load_phase_large.js
blob: 8cbdcb18268b1cada99d3cd15e6173b3c037f4ab (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
58
59
60
61
/**
 * Tests that a resumable index build large enough to spill to disk during the collection scan
 * phase writes its state to disk upon clean shutdown during the bulk load phase and is resumed
 * from the same phase to completion 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");
load("jstests/libs/sbe_util.js");          // For checkSBEEnabled.
load("jstests/libs/columnstore_util.js");  // For setUpServerForColumnStoreIndexTest.

const dbName = "test";

const rst = new ReplSetTest(
    {nodes: 1, nodeOptions: {setParameter: {maxIndexBuildMemoryUsageMegabytes: 50}}});
rst.startSet();
rst.initiate();

const columnstoreEnabled =
    checkSBEEnabled(rst.getPrimary().getDB(dbName), ["featureFlagColumnstoreIndexes"], true) &&
    setUpServerForColumnStoreIndexTest(rst.getPrimary().getDB(dbName));

// Insert enough data so that the collection scan spills to disk.
const coll = rst.getPrimary().getDB(dbName).getCollection(jsTestName());
const bulk = coll.initializeUnorderedBulkOp();
for (let i = 0; i < 100; i++) {
    // Each document is at least 1 MB.
    bulk.insert({a: i.toString().repeat(1024 * 1024)});
}
assert.commandWorked(bulk.execute());

ResumableIndexBuildTest.run(
    rst,
    dbName,
    coll.getName(),
    [[{a: 1}]],
    [{name: "hangIndexBuildDuringBulkLoadPhase", logIdWithIndexName: 4924400}],
    50,
    ["bulk load"],
    [{skippedPhaseLogID: 20391}]);

if (columnstoreEnabled) {
    ResumableIndexBuildTest.run(
        rst,
        dbName,
        coll.getName(),
        [[{"$**": "columnstore"}]],
        [{name: "hangIndexBuildDuringBulkLoadPhase", logIdWithIndexName: 4924400}],
        50,
        ["bulk load"],
        [{skippedPhaseLogID: 20391}]);
}
rst.stopSet();
})();