Skip to content

Commit

Permalink
SERVER-37498 remove slowBackgroundIndexBuild failpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
GWlodarek committed Jan 1, 2019
1 parent f721066 commit 46dd8e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
Expand Up @@ -38,7 +38,7 @@
primaryDB.runCommand({insert: collName, documents: documents, writeConcern: {w: 2}}));

assert.commandWorked(secondaryDB.adminCommand(
{configureFailPoint: "slowBackgroundIndexBuild", mode: "alwaysOn"}));
{configureFailPoint: "hangAfterStartingIndexBuild", mode: "alwaysOn"}));

// Start the index build on the primary.
assert.commandWorked(primaryDB.runCommand(
Expand All @@ -59,7 +59,7 @@

// Continue index build on the secondary. There should be no KeyTooLong error.
assert.commandWorked(
secondaryDB.adminCommand({configureFailPoint: "slowBackgroundIndexBuild", mode: "off"}));
secondaryDB.adminCommand({configureFailPoint: "hangAfterStartingIndexBuild", mode: "off"}));

// Make sure the index is successfully created.
assert.soon(() => {
Expand Down
26 changes: 11 additions & 15 deletions jstests/noPassthrough/characterize_index_builds_on_restart.js
Expand Up @@ -6,11 +6,12 @@
(function() {
'use strict';

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

const dbName = "test";
const collName = "coll";

const firstIndex = "firstIndex";
const secondIndex = "secondIndex";
const indexName = "collIndex";

function startStandalone() {
let mongod = MongoRunner.runMongod({cleanData: true});
Expand Down Expand Up @@ -67,14 +68,11 @@

if (isReplicaNode) {
assert.commandWorked(hangDB.adminCommand(
{configureFailPoint: "slowBackgroundIndexBuild", mode: "alwaysOn"}));
{configureFailPoint: "hangAfterStartingIndexBuild", mode: "alwaysOn"}));

db.runCommand({
createIndexes: collName,
indexes: [
{key: {i: 1}, name: firstIndex, background: true},
{key: {i: -1}, name: secondIndex, background: true},
],
indexes: [{key: {i: 1}, name: indexName, background: true}],
writeConcern: {w: w}
});
} else {
Expand All @@ -84,10 +82,7 @@
assert.throws(() => {
db.runCommand({
createIndexes: collName,
indexes: [
{key: {i: 1}, name: firstIndex, background: true},
{key: {i: -1}, name: secondIndex, background: true},
]
indexes: [{key: {i: 1}, name: indexName, background: true}]
});
});
}
Expand Down Expand Up @@ -157,8 +152,7 @@

mongod = restartStandalone(mongod);

checkForIndexRebuild(mongod, firstIndex, /*shouldExist=*/false);
checkForIndexRebuild(mongod, secondIndex, /*shouldExist=*/false);
checkForIndexRebuild(mongod, indexName, /*shouldExist=*/false);

shutdownStandalone(mongod);
}
Expand All @@ -174,14 +168,16 @@
addTestDocuments(primaryDB);
startIndexBuildAndCrash(primaryDB, /*isReplicaNode=*/true, /*w=*/2, secondaryDB);

// Wait for index build to begin on secondary before restarting.
checkLog.contains(secondary, "build index on: " + dbName + "." + collName);

let secondaryId = replSet.getNodeId(secondary);
replSet.stop(secondaryId);
replSet.remove(secondaryId);

let mongod = restartStandalone(secondary);

checkForIndexRebuild(mongod, firstIndex, /*shouldExist=*/true);
checkForIndexRebuild(mongod, secondIndex, /*shouldExist=*/true);
checkForIndexRebuild(mongod, indexName, /*shouldExist=*/true);

shutdownStandalone(mongod);
stopReplSet(replSet);
Expand Down
6 changes: 3 additions & 3 deletions jstests/noPassthrough/indexbg_drop.js
Expand Up @@ -47,8 +47,8 @@
}
assert.writeOK(bulk.execute({w: 2, wtimeout: replTest.kDefaultTimeoutMS}));

assert.commandWorked(
secondDB.adminCommand({configureFailPoint: "slowBackgroundIndexBuild", mode: "alwaysOn"}));
assert.commandWorked(secondDB.adminCommand(
{configureFailPoint: "hangAfterStartingIndexBuild", mode: "alwaysOn"}));

jsTest.log("Starting background indexing for test of: " + tojson(dc));

Expand All @@ -64,7 +64,7 @@

jsTest.log("Waiting on replication");
assert.commandWorked(
secondDB.adminCommand({configureFailPoint: "slowBackgroundIndexBuild", mode: "off"}));
secondDB.adminCommand({configureFailPoint: "hangAfterStartingIndexBuild", mode: "off"}));
replTest.awaitReplication();

print("Index list on master:");
Expand Down
9 changes: 2 additions & 7 deletions src/mongo/db/catalog/multi_index_block.cpp
Expand Up @@ -76,7 +76,6 @@ const StringData kCommitReadyMembersFieldName = "commitReadyMembers"_sd;
MONGO_FAIL_POINT_DEFINE(crashAfterStartingIndexBuild);
MONGO_FAIL_POINT_DEFINE(hangAfterStartingIndexBuild);
MONGO_FAIL_POINT_DEFINE(hangAfterStartingIndexBuildUnlocked);
MONGO_FAIL_POINT_DEFINE(slowBackgroundIndexBuild);
MONGO_FAIL_POINT_DEFINE(hangBeforeIndexBuildOf);
MONGO_FAIL_POINT_DEFINE(hangAfterIndexBuildOf);

Expand Down Expand Up @@ -350,18 +349,14 @@ Status MultiIndexBlock::insertAllDocumentsInCollection() {
if (_allowInterruption && !_opCtx->checkForInterruptNoAssert().isOK())
return _opCtx->checkForInterruptNoAssert();

if (!(retries || PlanExecutor::ADVANCED == state) ||
MONGO_FAIL_POINT(slowBackgroundIndexBuild)) {
log() << "Hanging index build due to failpoint";
invariant(_allowInterruption);
sleepmillis(1000);
if (!retries && PlanExecutor::ADVANCED != state) {
continue;
}

// Make sure we are working with the latest version of the document.
if (objToIndex.snapshotId() != _opCtx->recoveryUnit()->getSnapshotId() &&
!_collection->findDoc(_opCtx, loc, &objToIndex)) {
// doc was deleted so don't index it.
// Document was deleted so don't index it.
retries = 0;
continue;
}
Expand Down

0 comments on commit 46dd8e0

Please sign in to comment.