0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

SERVER-44859 fix plan_cache_index_create.js to work with two phase index builds

This commit is contained in:
Benety Goh 2019-11-27 16:09:10 +00:00 committed by evergreen
parent 22c12339cd
commit a4926b39a1

View File

@ -6,6 +6,8 @@
(function() {
"use strict";
load('jstests/noPassthrough/libs/index_build.js');
const dbName = "test";
const collName = "coll";
@ -76,6 +78,16 @@ function runTest({rst, readDB, writeDB}) {
assert.commandWorked(
readDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'alwaysOn'}));
// The commitIndexBuild oplog entry may block $planCacheStats on the secondary during oplog
// application because it will hold the PBWM while waiting for the index build to complete in
// the backgroud. Therefore, we get the primary to hold off on writing the commitIndexBuild
// oplog entry until we are ready to resume index builds on the secondary.
if (writeDB.getMongo().host != readDB.getMongo().host &&
IndexBuildTest.supportsTwoPhaseIndexBuild(writeDB.getMongo())) {
assert.commandWorked(writeDB.adminCommand(
{configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'alwaysOn'}));
}
// Build a "most selective" index in the background.
TestData.dbName = dbName;
TestData.collName = collName;
@ -102,6 +114,11 @@ function runTest({rst, readDB, writeDB}) {
// Disable the hang and wait for the index build to complete.
assert.commandWorked(
readDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'}));
// No effect if the fail point is already disabled.
assert.commandWorked(
writeDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'}));
assert.soon(() => !indexBuildIsRunning(readDB, "most_selective"));
createIdxShell({checkExitSuccess: true});