summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2018-05-23 15:37:08 -0400
committerEric Milkie <milkie@10gen.com>2018-05-25 11:22:27 -0400
commitec2b67ac05f7aaa05b990e18cd7c23109a2e6eb7 (patch)
tree899c4ef72d930ae526966de94383b6eb8b1e9251 /src/mongo/dbtests
parent8f170e92c1e874dc1ac3ebcdda2fd38afa92b258 (diff)
downloadmongo-ec2b67ac05f7aaa05b990e18cd7c23109a2e6eb7.tar.gz
SERVER-34790 ensure proper locks are held when doing reads or writes, via debug checks
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index ecef7cf5114..c558b7dd3d5 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -362,6 +362,8 @@ public:
static_cast<KVStorageEngine*>(_opCtx->getServiceContext()->getStorageEngine())
->getCatalog();
+ AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_IS, LockMode::MODE_IS);
+
// getCollectionIdent() returns the ident for the given namespace in the KVCatalog.
// getAllIdents() actually looks in the RecordStore for a list of all idents, and is thus
// versioned by timestamp. These tests do not do any renames, so we can expect the
@@ -1703,6 +1705,8 @@ public:
std::string sysProfileIndexIdent;
for (auto& tuple : {std::tie(nss, collIdent, indexIdent),
std::tie(sysProfile, sysProfileIdent, sysProfileIndexIdent)}) {
+ AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_X, LockMode::MODE_X);
+
// Save the pre-state idents so we can capture the specific idents related to collection
// creation.
std::vector<std::string> origIdents = kvCatalog->getAllIdents(_opCtx);
@@ -1718,8 +1722,6 @@ public:
reset(nss);
}
- AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_X, LockMode::MODE_X);
-
// Bind the local values to the variables in the parent scope.
auto& collIdent = std::get<1>(tuple);
auto& indexIdent = std::get<2>(tuple);
@@ -2139,7 +2141,11 @@ public:
auto kvStorageEngine =
dynamic_cast<KVStorageEngine*>(_opCtx->getServiceContext()->getStorageEngine());
KVCatalog* kvCatalog = kvStorageEngine->getCatalog();
- std::vector<std::string> origIdents = kvCatalog->getAllIdents(_opCtx);
+ std::vector<std::string> origIdents;
+ {
+ AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_IS, LockMode::MODE_IS);
+ origIdents = kvCatalog->getAllIdents(_opCtx);
+ }
auto indexSpec = BSON("createIndexes" << nss.coll() << "ns" << nss.ns() << "v"
<< static_cast<int>(kIndexVersion)
@@ -2162,6 +2168,7 @@ public:
ASSERT_OK(doAtomicApplyOps(nss.db().toString(), {createIndexOp}));
+ AutoGetCollection autoColl(_opCtx, nss, LockMode::MODE_IS, LockMode::MODE_IS);
const std::string indexIdent = getNewIndexIdent(kvCatalog, origIdents);
assertIdentsMissingAtTimestamp(
kvCatalog, "", indexIdent, beforeBuildTime.asTimestamp());