summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/restart_index_build_if_resume_interrupted_by_shutdown.js
blob: 70b91ac5ccdbdef9274be567160e7267d447e607 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
 * 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.

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", "featureFlagSbeFull"], true);

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}]);

// TODO (SERVER-65978): Add side writes to these test cases once they are supported by column store
// index builds.
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
        [],
        [{a: 4}, {a: 5}]);

    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: [11, 22, 33]},  // initial doc
        [],
        [{a: 99}, {a: 100}]);
}
rst.stopSet();
})();