summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/indexupdatetests.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2018-12-07 13:40:17 -0500
committerLouis Williams <louis.williams@mongodb.com>2018-12-13 11:41:02 -0500
commitb4cb96852037aecfab27aa7b72a2ee586a3aa2e3 (patch)
tree8cdf4b47255d577a291b8714f9ae54b89942ec26 /src/mongo/dbtests/indexupdatetests.cpp
parent6d900523fac41857c7fe05a34dd480d1f4b56ec8 (diff)
downloadmongo-b4cb96852037aecfab27aa7b72a2ee586a3aa2e3.tar.gz
SERVER-38453 SortedDataInterface should expose a method to determine whether or not a key is a duplicate
SERVER-38036 Turn on hybrid builds for background, unique indexes
Diffstat (limited to 'src/mongo/dbtests/indexupdatetests.cpp')
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index a96b827cc14..2b864eba1b1 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -170,18 +170,16 @@ public:
coll = db->createCollection(&_opCtx, _ns);
OpDebug* const nullOpDebug = nullptr;
- coll->insertDocument(&_opCtx,
- InsertStatement(BSON("_id" << 1 << "a"
- << "dup")),
- nullOpDebug,
- true)
- .transitional_ignore();
- coll->insertDocument(&_opCtx,
- InsertStatement(BSON("_id" << 2 << "a"
- << "dup")),
- nullOpDebug,
- true)
- .transitional_ignore();
+ ASSERT_OK(coll->insertDocument(&_opCtx,
+ InsertStatement(BSON("_id" << 1 << "a"
+ << "dup")),
+ nullOpDebug,
+ true));
+ ASSERT_OK(coll->insertDocument(&_opCtx,
+ InsertStatement(BSON("_id" << 2 << "a"
+ << "dup")),
+ nullOpDebug,
+ true));
wunit.commit();
}
@@ -204,8 +202,22 @@ public:
<< background);
ASSERT_OK(indexer.init(spec).getStatus());
+ auto desc =
+ coll->getIndexCatalog()->findIndexByName(&_opCtx, "a", true /* includeUnfinished */);
+ ASSERT(desc);
+
const Status status = indexer.insertAllDocumentsInCollection();
- ASSERT_EQUALS(status.code(), ErrorCodes::DuplicateKey);
+ if (!coll->getIndexCatalog()->getEntry(desc)->isBuilding()) {
+ ASSERT_EQUALS(status.code(), ErrorCodes::DuplicateKey);
+ return;
+ }
+
+ // Hybrid index builds, with an interceptor, do not detect duplicates until they commit.
+ ASSERT_OK(status);
+
+ WriteUnitOfWork wunit(&_opCtx);
+ ASSERT_THROWS_CODE(indexer.commit(), AssertionException, ErrorCodes::DuplicateKey);
+ wunit.commit();
}
};