diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-07-01 15:50:38 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-08 21:05:44 +0000 |
commit | 372199eb2ab0749faaf7d696a2ae8622ce6603c6 (patch) | |
tree | 4096017f7935f1dae2ba811de16914b57d398836 /src/mongo/db/catalog/multi_index_block.cpp | |
parent | acd6c3d067a90f6cf37b6802160b505f7935218b (diff) | |
download | mongo-372199eb2ab0749faaf7d696a2ae8622ce6603c6.tar.gz |
SERVER-49244 Test that resumable index builds write state to disk on clean shutdown
Diffstat (limited to 'src/mongo/db/catalog/multi_index_block.cpp')
-rw-r--r-- | src/mongo/db/catalog/multi_index_block.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index 71db6045749..46d4604c113 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -36,6 +36,7 @@ #include <ostream> #include "mongo/base/error_codes.h" +#include "mongo/bson/simple_bsonelement_comparator.h" #include "mongo/db/audit.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog.h" @@ -66,8 +67,8 @@ MONGO_FAIL_POINT_DEFINE(hangAfterSettingUpIndexBuild); MONGO_FAIL_POINT_DEFINE(hangAfterSettingUpIndexBuildUnlocked); MONGO_FAIL_POINT_DEFINE(hangAfterStartingIndexBuild); MONGO_FAIL_POINT_DEFINE(hangAfterStartingIndexBuildUnlocked); -MONGO_FAIL_POINT_DEFINE(hangBeforeIndexBuildOf); -MONGO_FAIL_POINT_DEFINE(hangAfterIndexBuildOf); +MONGO_FAIL_POINT_DEFINE(hangIndexBuildDuringCollectionScanPhaseBeforeInsertion); +MONGO_FAIL_POINT_DEFINE(hangIndexBuildDuringCollectionScanPhaseAfterInsertion); MONGO_FAIL_POINT_DEFINE(leaveIndexBuildUnfinishedForShutdown); MultiIndexBlock::~MultiIndexBlock() { @@ -310,14 +311,20 @@ StatusWith<std::vector<BSONObj>> MultiIndexBlock::init(OperationContext* opCtx, void failPointHangDuringBuild(FailPoint* fp, StringData where, const BSONObj& doc) { fp->executeIf( [&](const BSONObj& data) { - int i = doc.getIntField("i"); - LOGV2( - 20386, "Hanging {where} index build of i={i}", "where"_attr = where, "i"_attr = i); + LOGV2(20386, + "Hanging index build during collection scan phase insertion", + "where"_attr = where, + "doc"_attr = doc); + fp->pauseWhileSet(); }, - [&](const BSONObj& data) { - int i = doc.getIntField("i"); - return data["i"].numberInt() == i; + [&doc](const BSONObj& data) { + auto fieldsToMatch = data.getObjectField("fieldsToMatch"); + return std::all_of( + fieldsToMatch.begin(), fieldsToMatch.end(), [&doc](const auto& elem) { + return SimpleBSONElementComparator::kInstance.evaluate(elem == + doc[elem.fieldName()]); + }); }); } @@ -407,7 +414,8 @@ Status MultiIndexBlock::insertAllDocumentsInCollection(OperationContext* opCtx, progress->setTotalWhileRunning(collection->numRecords(opCtx)); - failPointHangDuringBuild(&hangBeforeIndexBuildOf, "before", objToIndex); + failPointHangDuringBuild( + &hangIndexBuildDuringCollectionScanPhaseBeforeInsertion, "before", objToIndex); // The external sorter is not part of the storage engine and therefore does not need a // WriteUnitOfWork to write keys. @@ -416,7 +424,8 @@ Status MultiIndexBlock::insertAllDocumentsInCollection(OperationContext* opCtx, return ret; } - failPointHangDuringBuild(&hangAfterIndexBuildOf, "after", objToIndex); + failPointHangDuringBuild( + &hangIndexBuildDuringCollectionScanPhaseAfterInsertion, "after", objToIndex); // Go to the next document. progress->hit(); |