mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
SERVER-28251 Fix race condition in index_killop.js
This commit is contained in:
parent
b6895cfda2
commit
6a416de433
@ -47,9 +47,6 @@
|
|||||||
// Kill the index build.
|
// Kill the index build.
|
||||||
assert.commandWorked(testDB.killOp(opId));
|
assert.commandWorked(testDB.killOp(opId));
|
||||||
|
|
||||||
assert.commandWorked(
|
|
||||||
testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'}));
|
|
||||||
|
|
||||||
// Wait for the index build to stop.
|
// Wait for the index build to stop.
|
||||||
assert.soon(function() {
|
assert.soon(function() {
|
||||||
return getIndexBuildOpId() == -1;
|
return getIndexBuildOpId() == -1;
|
||||||
@ -62,6 +59,9 @@
|
|||||||
// Check that no new index has been created. This verifies that the index build was aborted
|
// Check that no new index has been created. This verifies that the index build was aborted
|
||||||
// rather than successfully completed.
|
// rather than successfully completed.
|
||||||
assert.eq([{_id: 1}], testDB.test.getIndexKeys());
|
assert.eq([{_id: 1}], testDB.test.getIndexKeys());
|
||||||
|
|
||||||
|
assert.commandWorked(
|
||||||
|
testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'}));
|
||||||
}
|
}
|
||||||
|
|
||||||
testAbortIndexBuild({background: true});
|
testAbortIndexBuild({background: true});
|
||||||
|
@ -320,11 +320,20 @@ Status MultiIndexBlockImpl::insertAllDocumentsInCollection(std::set<RecordId>* d
|
|||||||
PlanExecutor::ExecState state;
|
PlanExecutor::ExecState state;
|
||||||
int retries = 0; // non-zero when retrying our last document.
|
int retries = 0; // non-zero when retrying our last document.
|
||||||
while (retries ||
|
while (retries ||
|
||||||
(PlanExecutor::ADVANCED == (state = exec->getNextSnapshotted(&objToIndex, &loc)))) {
|
(PlanExecutor::ADVANCED == (state = exec->getNextSnapshotted(&objToIndex, &loc))) ||
|
||||||
|
MONGO_FAIL_POINT(hangAfterStartingIndexBuild)) {
|
||||||
try {
|
try {
|
||||||
if (_allowInterruption)
|
if (_allowInterruption)
|
||||||
_opCtx->checkForInterrupt();
|
_opCtx->checkForInterrupt();
|
||||||
|
|
||||||
|
if (!(retries || (PlanExecutor::ADVANCED == state))) {
|
||||||
|
// The only reason we are still in the loop is hangAfterStartingIndexBuild.
|
||||||
|
log() << "Hanging index build due to 'hangAfterStartingIndexBuild' failpoint";
|
||||||
|
invariant(_allowInterruption);
|
||||||
|
sleepmillis(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we are working with the latest version of the document.
|
// Make sure we are working with the latest version of the document.
|
||||||
if (objToIndex.snapshotId() != _opCtx->recoveryUnit()->getSnapshotId() &&
|
if (objToIndex.snapshotId() != _opCtx->recoveryUnit()->getSnapshotId() &&
|
||||||
!_collection->findDoc(_opCtx, loc, &objToIndex)) {
|
!_collection->findDoc(_opCtx, loc, &objToIndex)) {
|
||||||
@ -383,18 +392,6 @@ Status MultiIndexBlockImpl::insertAllDocumentsInCollection(std::set<RecordId>* d
|
|||||||
WorkingSetCommon::toStatusString(objToIndex.value()),
|
WorkingSetCommon::toStatusString(objToIndex.value()),
|
||||||
state == PlanExecutor::IS_EOF);
|
state == PlanExecutor::IS_EOF);
|
||||||
|
|
||||||
if (MONGO_FAIL_POINT(hangAfterStartingIndexBuild)) {
|
|
||||||
// Need the index build to hang before the progress meter is marked as finished so we can
|
|
||||||
// reliably check that the index build has actually started in js tests.
|
|
||||||
while (MONGO_FAIL_POINT(hangAfterStartingIndexBuild)) {
|
|
||||||
log() << "Hanging index build due to 'hangAfterStartingIndexBuild' failpoint";
|
|
||||||
sleepmillis(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for interrupt to allow for killop prior to index build completion.
|
|
||||||
_opCtx->checkForInterrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MONGO_FAIL_POINT(hangAfterStartingIndexBuildUnlocked)) {
|
if (MONGO_FAIL_POINT(hangAfterStartingIndexBuildUnlocked)) {
|
||||||
// Unlock before hanging so replication recognizes we've completed.
|
// Unlock before hanging so replication recognizes we've completed.
|
||||||
Locker::LockSnapshot lockInfo;
|
Locker::LockSnapshot lockInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user