summaryrefslogtreecommitdiff
path: root/jstests/serverless/shard_split_abort_on_setfcv.js
blob: e6b333e6ce87262793cc8b3a0d567c3d8f6fbf16 (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
/*
 * Prove that shard splits are eagerly aborted when the `setFeatureCompatibilityVersion` command is
 * received for both upgrade and downgrade paths.
 *
 * @tags: [requires_fcv_63, serverless]
 */

import {ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";

load("jstests/libs/fail_point_util.js");

// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
const test = new ShardSplitTest({quickGarbageCollection: true});
test.addRecipientNodes();

const donorPrimary = test.donor.getPrimary();
const tenantIds = [ObjectId(), ObjectId()];
const pauseAfterBlockingFp = configureFailPoint(donorPrimary, "pauseShardSplitAfterBlocking");

jsTestLog("Test FCV Downgrade");
const split = test.createSplitOperation(tenantIds);
const commitThread = split.commitAsync();
pauseAfterBlockingFp.wait();
assert.commandWorked(
    donorPrimary.adminCommand({setFeatureCompatibilityVersion: lastContinuousFCV}));
pauseAfterBlockingFp.off();
assert.commandFailedWithCode(commitThread.returnData(), ErrorCodes.TenantMigrationAborted);

jsTestLog("Test FCV Upgrade");
if (lastContinuousFCV == "6.2") {
    const secondSplit = test.createSplitOperation(tenantIds);
    assert.commandFailedWithCode(secondSplit.commit(), ErrorCodes.IllegalOperation);
} else {
    // `forgetShardSplit` will not be available until the downgraded version also supports the
    // 'shard split' feature.
    split.forget();
    test.cleanupSuccesfulAborted(split.migrationId, tenantIds);

    test.addRecipientNodes();
    const pauseAfterBlockingFp = configureFailPoint(donorPrimary, "pauseShardSplitAfterBlocking");
    const secondSplit = test.createSplitOperation(tenantIds);
    const commitThread = secondSplit.commitAsync();
    pauseAfterBlockingFp.wait();
    assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
    pauseAfterBlockingFp.off();
    assert.commandFailedWithCode(commitThread.returnData(), ErrorCodes.TenantMigrationAborted);
    secondSplit.forget();
    test.cleanupSuccesfulAborted(secondSplit.migrationId, tenantIds);
}

test.stop();