blob: f6491f9c70e41909bf60b6f55f8a3eef611c24fa (
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
|
/**
* Ensures that index builds encountering a DataCorruptionDetected error log and increment a metric.
*
* @tags: [
* requires_fcv_71,
* requires_replication,
* ]
*/
(function() {
"use strict";
load('jstests/noPassthrough/libs/index_build.js');
load("jstests/libs/fail_point_util.js");
const rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
const dbName = 'test';
const collName = 'coll';
const primary = rst.getPrimary();
const primaryDB = primary.getDB(dbName);
const primaryColl = primaryDB.getCollection(collName);
assert.commandWorked(primaryColl.insert({a: 1}));
rst.awaitReplication();
const hangAfterInitializingIndexBuild =
configureFailPoint(primary, "hangAfterInitializingIndexBuild");
const createIdx = IndexBuildTest.startIndexBuild(
primary, primaryColl.getFullName(), {a: 1}, null, [ErrorCodes.DataCorruptionDetected]);
hangAfterInitializingIndexBuild.wait();
const WTRecordStoreUassertOutOfOrder =
configureFailPoint(primary, "WTRecordStoreUassertOutOfOrder");
const hangBeforeAbort =
configureFailPoint(primary, "hangIndexBuildBeforeTransitioningReplStateTokAwaitPrimaryAbort");
hangAfterInitializingIndexBuild.off();
hangBeforeAbort.wait();
// Index build: data corruption detected.
checkLog.containsJson(primary, 7333600);
assert.eq(1, primaryDB.serverStatus().indexBuilds.failedDueToDataCorruption);
// Disable out-of-order failpoint so clean-up can succeed.
WTRecordStoreUassertOutOfOrder.off();
hangBeforeAbort.off();
jsTestLog("Waiting for threads to join");
createIdx();
IndexBuildTest.assertIndexesSoon(primaryColl, 1, ['_id_']);
rst.stopSet();
})();
|