summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2014-10-07 12:13:21 -0400
committerGeert Bosch <geert@mongodb.com>2014-10-09 18:21:06 -0400
commit5ea4221f81e7af9272e4e687d516bb439ef29498 (patch)
tree8bfee151ed5a434935681e17a9f6e26a8c080a33 /src/mongo/dbtests
parentff10cf8c748997338f51de2de61520e17518758c (diff)
downloadmongo-5ea4221f81e7af9272e4e687d516bb439ef29498.tar.gz
SERVER-14668: Collection level locking for update path
Temporarily disable collection locking for MMAPv1.
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/clienttests.cpp2
-rw-r--r--src/mongo/dbtests/counttests.cpp8
-rw-r--r--src/mongo/dbtests/dbhelper_tests.cpp2
-rw-r--r--src/mongo/dbtests/documentsourcetests.cpp3
-rw-r--r--src/mongo/dbtests/indexcatalogtests.cpp2
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp6
-rw-r--r--src/mongo/dbtests/namespacetests.cpp4
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp12
-rw-r--r--src/mongo/dbtests/query_stage_and.cpp80
-rw-r--r--src/mongo/dbtests/query_stage_collscan.cpp4
-rw-r--r--src/mongo/dbtests/query_stage_count.cpp14
-rw-r--r--src/mongo/dbtests/query_stage_delete.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp2
-rw-r--r--src/mongo/dbtests/querytests.cpp45
-rw-r--r--src/mongo/dbtests/threadedtests.cpp8
15 files changed, 97 insertions, 97 deletions
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp
index 039bf9f3e36..01584aed69d 100644
--- a/src/mongo/dbtests/clienttests.cpp
+++ b/src/mongo/dbtests/clienttests.cpp
@@ -142,7 +142,7 @@ namespace ClientTests {
db.insert(ns(), BSON("x" << 1 << "y" << 2));
db.insert(ns(), BSON("x" << 2 << "y" << 2));
- Collection* collection = ctx.ctx().db()->getCollection( &txn, ns() );
+ Collection* collection = ctx.getCollection();
ASSERT( collection );
IndexCatalog* indexCatalog = collection->getIndexCatalog();
diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp
index 31dabc13a97..4d0f87bb811 100644
--- a/src/mongo/dbtests/counttests.cpp
+++ b/src/mongo/dbtests/counttests.cpp
@@ -43,9 +43,9 @@ namespace CountTests {
class Base {
public:
- Base() : lk(_txn.lockState(), ns()),
- _context(&_txn, ns()),
- _client(&_txn) {
+ Base() : _lk(_txn.lockState(), nsToDatabaseSubstring(ns()), newlm::MODE_X),
+ _context(&_txn, ns()),
+ _client(&_txn) {
_database = _context.db();
{
WriteUnitOfWork wunit(&_txn);
@@ -104,7 +104,7 @@ namespace CountTests {
OperationContextImpl _txn;
- Lock::DBWrite lk;
+ Lock::DBLock _lk;
Client::Context _context;
diff --git a/src/mongo/dbtests/dbhelper_tests.cpp b/src/mongo/dbtests/dbhelper_tests.cpp
index 3706b5dac48..a49fb91bd9f 100644
--- a/src/mongo/dbtests/dbhelper_tests.cpp
+++ b/src/mongo/dbtests/dbhelper_tests.cpp
@@ -62,7 +62,7 @@ namespace mongo {
{
// Remove _id range [_min, _max).
- Lock::DBWrite lk(txn.lockState(), ns);
+ Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(ns), newlm::MODE_X);
WriteUnitOfWork wunit(&txn);
Client::Context ctx(&txn, ns );
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp
index 1a17bfa7c8c..65ef3f1ee63 100644
--- a/src/mongo/dbtests/documentsourcetests.cpp
+++ b/src/mongo/dbtests/documentsourcetests.cpp
@@ -178,8 +178,7 @@ namespace DocumentSourceTests {
CanonicalQuery* cq;
uassertStatusOK(CanonicalQuery::canonicalize(ns, /*query=*/BSONObj(), &cq));
PlanExecutor* execBare;
- uassertStatusOK(getExecutor(&_opCtx, ctx.ctx().db()->getCollection(&_opCtx, ns),
- cq, &execBare));
+ uassertStatusOK(getExecutor(&_opCtx, ctx.getCollection(), cq, &execBare));
_exec.reset(execBare);
_exec->saveState();
diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp
index d66633f07b7..a18488c542a 100644
--- a/src/mongo/dbtests/indexcatalogtests.cpp
+++ b/src/mongo/dbtests/indexcatalogtests.cpp
@@ -35,7 +35,7 @@ namespace IndexCatalogTests {
OperationContextImpl txn;
Client::WriteContext ctx(&txn, _ns);
- _db = ctx.ctx().db();
+ _db = ctx.db();
_coll = _db->createCollection(&txn, _ns);
_catalog = _coll->getIndexCatalog();
ctx.commit();
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 1e9e3a520b1..28d1d707289 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -65,7 +65,7 @@ namespace IndexUpdateTests {
getGlobalEnvironment()->unsetKillAllOperations();
}
Collection* collection() {
- return _ctx.ctx().db()->getCollection( &_txn, _ns );
+ return _ctx.getCollection();
}
protected:
// QUERY_MIGRATION
@@ -663,7 +663,9 @@ namespace IndexUpdateTests {
memcpy( infoRecord->data(), indexInfo.objdata(), indexInfo.objsize() );
addRecordToRecListInExtent( infoRecord, infoLoc );
- return new IndexCatalog::IndexBuildBlock( _ctx.ctx().db()->getCollection( _ns )->getIndexCatalog(), name, infoLoc );
+ return new IndexCatalog::IndexBuildBlock( _ctx.getCollection()->getIndexCatalog(),
+ name,
+ infoLoc );
}
};
#endif
diff --git a/src/mongo/dbtests/namespacetests.cpp b/src/mongo/dbtests/namespacetests.cpp
index a33f33ef06c..d755d355a82 100644
--- a/src/mongo/dbtests/namespacetests.cpp
+++ b/src/mongo/dbtests/namespacetests.cpp
@@ -524,7 +524,7 @@ namespace NamespaceTests {
OperationContextImpl txn;
- Lock::DBWrite lk(txn.lockState(), dbName);
+ Lock::DBLock lk(txn.lockState(), dbName, newlm::MODE_X);
bool justCreated;
Database* db = dbHolder().openDb(&txn, dbName, &justCreated);
@@ -567,7 +567,7 @@ namespace NamespaceTests {
OperationContextImpl txn;
- Lock::DBWrite lk(txn.lockState(), dbName);
+ Lock::DBLock lk(txn.lockState(), dbName, newlm::MODE_X);
bool justCreated;
Database* db = dbHolder().openDb(&txn, dbName, &justCreated);
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index 8b77c8f4eb4..6687c4a47f3 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -191,7 +191,7 @@ namespace QueryPlanExecutor {
BSONObj filterObj = fromjson("{_id: {$gt: 0}}");
- Collection* coll = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* coll = ctx.getCollection();
scoped_ptr<PlanExecutor> exec(makeCollScanExec(coll, filterObj));
registerExec(exec.get());
@@ -271,7 +271,7 @@ namespace QueryPlanExecutor {
std::auto_ptr<WorkingSet> ws(new WorkingSet());
std::auto_ptr<PipelineProxyStage> proxy(
new PipelineProxyStage(pipeline, innerExec, ws.get()));
- Collection* collection = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* collection = ctx.getCollection();
boost::scoped_ptr<PlanExecutor> outerExec(
new PlanExecutor(&_txn, ws.release(), proxy.release(), collection));
@@ -343,7 +343,7 @@ namespace QueryPlanExecutor {
BSONObj filterObj = fromjson("{a: {$gte: 2}}");
- Collection* coll = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* coll = ctx.getCollection();
scoped_ptr<PlanExecutor> exec(makeCollScanExec(coll, filterObj));
BSONObj objOut;
@@ -403,7 +403,7 @@ namespace QueryPlanExecutor {
BSONObj filterObj = fromjson("{_id: {$gt: 0}, b: {$gt: 0}}");
- Collection* coll = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* coll = ctx.getCollection();
PlanExecutor* exec = makeCollScanExec(coll,filterObj);
// Make a client cursor from the runner.
@@ -412,7 +412,7 @@ namespace QueryPlanExecutor {
// There should be one cursor before invalidation,
// and zero cursors after invalidation.
ASSERT_EQUALS(1U, numCursors());
- ctx.ctx().db()->getCollection( &_txn, ns() )->cursorCache()->invalidateAll(false);
+ coll->cursorCache()->invalidateAll(false);
ASSERT_EQUALS(0U, numCursors());
ctx.commit();
}
@@ -428,7 +428,7 @@ namespace QueryPlanExecutor {
Client::WriteContext ctx(&_txn, ns());
insert(BSON("a" << 1 << "b" << 1));
- Collection* collection = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* collection = ctx.getCollection();
BSONObj filterObj = fromjson("{_id: {$gt: 0}, b: {$gt: 0}}");
PlanExecutor* exec = makeCollScanExec(collection, filterObj);
diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp
index 171e916b8c2..ddc255bfce0 100644
--- a/src/mongo/dbtests/query_stage_and.cpp
+++ b/src/mongo/dbtests/query_stage_and.cpp
@@ -157,8 +157,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -259,8 +259,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -345,8 +345,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -394,8 +394,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -446,8 +446,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -497,8 +497,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -558,8 +558,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -617,8 +617,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -676,8 +676,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -724,8 +724,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -776,8 +776,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -834,8 +834,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -897,8 +897,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1014,8 +1014,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1067,8 +1067,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1112,8 +1112,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1160,8 +1160,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1205,8 +1205,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1267,8 +1267,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
@@ -1320,8 +1320,8 @@ namespace QueryStageAnd {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Database* db = ctx.ctx().db();
- Collection* coll = db->getCollection(&_txn, ns());
+ Database* db = ctx.db();
+ Collection* coll = ctx.getCollection();
if (!coll) {
coll = db->createCollection(&_txn, ns());
}
diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp
index 689ce3677e9..9cbf2dc22f7 100644
--- a/src/mongo/dbtests/query_stage_collscan.cpp
+++ b/src/mongo/dbtests/query_stage_collscan.cpp
@@ -246,7 +246,7 @@ namespace QueryStageCollectionScan {
void run() {
Client::WriteContext ctx(&_txn, ns());
- Collection* coll = ctx.ctx().db()->getCollection( &_txn, ns() );
+ Collection* coll = ctx.getCollection();
// Get the DiskLocs that would be returned by an in-order scan.
vector<DiskLoc> locs;
@@ -308,7 +308,7 @@ namespace QueryStageCollectionScan {
public:
void run() {
Client::WriteContext ctx(&_txn, ns());
- Collection* coll = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* coll = ctx.getCollection();
// Get the DiskLocs that would be returned by an in-order scan.
vector<DiskLoc> locs;
diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp
index 6c70aa1280a..8e18509342e 100644
--- a/src/mongo/dbtests/query_stage_count.cpp
+++ b/src/mongo/dbtests/query_stage_count.cpp
@@ -121,7 +121,7 @@ namespace QueryStageCount {
// Set up the count stage
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
verify(params.descriptor);
params.startKey = BSON("a" << 1);
params.startKeyInclusive = true;
@@ -155,7 +155,7 @@ namespace QueryStageCount {
// Set up the count stage
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 3);
params.startKeyInclusive = true;
params.endKey = BSON("" << 7);
@@ -188,7 +188,7 @@ namespace QueryStageCount {
// Set up the count stage
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 3);
params.startKeyInclusive = false;
params.endKey = BSON("" << 7);
@@ -217,7 +217,7 @@ namespace QueryStageCount {
// Set up count, and run
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 2);
params.startKeyInclusive = false;
params.endKey = BSON("" << 3);
@@ -247,7 +247,7 @@ namespace QueryStageCount {
// Set up count, and run
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 2);
params.startKeyInclusive = false;
params.endKey = BSON("" << 3);
@@ -278,7 +278,7 @@ namespace QueryStageCount {
// Set up count, and run
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 2);
params.startKeyInclusive = false;
params.endKey = BSON("" << 3);
@@ -602,7 +602,7 @@ namespace QueryStageCount {
// Set up count stage
CountScanParams params;
- params.descriptor = getIndex(ctx.ctx().db(), BSON("a" << 1));
+ params.descriptor = getIndex(ctx.db(), BSON("a" << 1));
params.startKey = BSON("" << 1);
params.startKeyInclusive = true;
params.endKey = BSON("" << 1);
diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp
index b2e6c9db085..19ce4fe37cd 100644
--- a/src/mongo/dbtests/query_stage_delete.cpp
+++ b/src/mongo/dbtests/query_stage_delete.cpp
@@ -110,7 +110,7 @@ namespace QueryStageDelete {
void run() {
Client::WriteContext ctx(&_txn, ns());
- Collection* coll = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* coll = ctx.getCollection();
// Get the DiskLocs that would be returned by an in-order scan.
vector<DiskLoc> locs;
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index 1d72dccca7d..ecc406b1be1 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -86,7 +86,7 @@ namespace QueryStageSubplan {
CanonicalQuery* cq;
ASSERT_OK(CanonicalQuery::canonicalize(ns(), query, &cq));
- Collection* collection = ctx.ctx().db()->getCollection(&_txn, ns());
+ Collection* collection = ctx.getCollection();
// Get planner params.
QueryPlannerParams plannerParams;
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index f092eb926a4..02e3bcaebd0 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -250,15 +250,13 @@ namespace QueryTests {
{
// Check internal server handoff to getmore.
- Lock::DBWrite lk(_txn.lockState(), ns);
- WriteUnitOfWork wunit(&_txn);
- Client::Context ctx(&_txn, ns );
- ClientCursorPin clientCursor( ctx.db()->getCollection(&_txn, ns), cursorId );
+ Client::WriteContext ctx(&_txn, ns);
+ ClientCursorPin clientCursor( ctx.getCollection(), cursorId );
// pq doesn't exist if it's a runner inside of the clientcursor.
// ASSERT( clientCursor.c()->pq );
// ASSERT_EQUALS( 2, clientCursor.c()->pq->getNumToReturn() );
ASSERT_EQUALS( 2, clientCursor.c()->pos() );
- wunit.commit();
+ ctx.commit();
}
cursor = _client.getMore( ns, cursorId );
@@ -596,7 +594,7 @@ namespace QueryTests {
}
void run() {
const char *ns = "unittests.querytests.OplogReplaySlaveReadTill";
- Lock::DBWrite lk(_txn.lockState(), ns);
+ Lock::DBLock lk(_txn.lockState(), "unittests", newlm::MODE_X);
WriteUnitOfWork wunit(&_txn);
Client::Context ctx(&_txn, ns );
@@ -1164,14 +1162,15 @@ namespace QueryTests {
}
void run() {
string err;
- Client::WriteContext ctx(&_txn, "unittests" );
+ Client::WriteContext ctx(&_txn, ns());
- // note that extents are always at least 4KB now - so this will get rounded up a bit.
- ASSERT( userCreateNS( &_txn, ctx.ctx().db(), ns(),
- fromjson( "{ capped : true, size : 2000 }" ), false ).isOK() );
- for ( int i=0; i<200; i++ ) {
+ // note that extents are always at least 4KB now - so this will get rounded up
+ // a bit.
+ ASSERT( userCreateNS(&_txn, ctx.db(), ns(),
+ fromjson( "{ capped : true, size : 2000 }" ), false ).isOK() );
+ for (int i = 0; i < 200; i++) {
insertNext();
- ASSERT( count() < 90 );
+ ASSERT(count() < 90);
}
int a = count();
@@ -1214,7 +1213,7 @@ namespace QueryTests {
}
void run() {
- Client::WriteContext ctx(&_txn, "unittests" );
+ Client::WriteContext ctx(&_txn, ns());
for ( int i=0; i<50; i++ ) {
insert( ns() , BSON( "_id" << i << "x" << i * 2 ) );
@@ -1224,8 +1223,8 @@ namespace QueryTests {
ASSERT_EQUALS( 50 , count() );
BSONObj res;
- ASSERT( Helpers::findOne( &_txn, ctx.ctx().db()->getCollection( &_txn, ns() ),
- BSON( "_id" << 20 ) , res , true ) );
+ ASSERT( Helpers::findOne(&_txn, ctx.getCollection(),
+ BSON("_id" << 20) , res , true));
ASSERT_EQUALS( 40 , res["x"].numberInt() );
ASSERT( Helpers::findById( &_txn, ctx.ctx().db(), ns() , BSON( "_id" << 20 ) , res ) );
@@ -1241,15 +1240,15 @@ namespace QueryTests {
{
Timer t;
for ( int i=0; i<n; i++ ) {
- ASSERT( Helpers::findOne( &_txn, ctx.ctx().db()->getCollection(&_txn, ns()),
- BSON( "_id" << 20 ), res, true ) );
+ ASSERT( Helpers::findOne(&_txn, ctx.getCollection(),
+ BSON( "_id" << 20 ), res, true ) );
}
slow = t.micros();
}
{
Timer t;
for ( int i=0; i<n; i++ ) {
- ASSERT( Helpers::findById( &_txn, ctx.ctx().db(), ns() , BSON( "_id" << 20 ) , res ) );
+ ASSERT( Helpers::findById(&_txn, ctx.db(), ns() , BSON( "_id" << 20 ) , res ) );
}
fast = t.micros();
}
@@ -1266,7 +1265,7 @@ namespace QueryTests {
}
void run() {
- Client::WriteContext ctx(&_txn, "unittests" );
+ Client::WriteContext ctx(&_txn, ns());
for ( int i=0; i<1000; i++ ) {
insert( ns() , BSON( "_id" << i << "x" << i * 2 ) );
@@ -1278,7 +1277,7 @@ namespace QueryTests {
BSONObj res;
for ( int i=0; i<1000; i++ ) {
- bool found = Helpers::findById( &_txn, ctx.ctx().db(), ns() , BSON( "_id" << i ) , res );
+ bool found = Helpers::findById( &_txn, ctx.db(), ns() , BSON( "_id" << i ) , res );
ASSERT_EQUALS( i % 2 , int(found) );
}
@@ -1290,7 +1289,7 @@ namespace QueryTests {
}
void run() {
- Client::WriteContext ctx(&_txn, "unittests" );
+ Client::WriteContext ctx(&_txn, ns());
for ( int i=0; i<1000; i++ ) {
insert( ns() , BSON( "_id" << i << "x" << i * 2 ) );
@@ -1406,12 +1405,12 @@ namespace QueryTests {
public:
CollectionInternalBase( const char *nsLeaf ) :
CollectionBase( nsLeaf ),
- _lk(_txn.lockState(), ns() ),
+ _lk(_txn.lockState(), "unittests", newlm::MODE_X),
_ctx(&_txn, ns()) {
}
private:
- Lock::DBWrite _lk;
+ Lock::DBLock _lk;
Client::Context _ctx;
};
diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp
index 47ec740bd30..62ab464fc98 100644
--- a/src/mongo/dbtests/threadedtests.cpp
+++ b/src/mongo/dbtests/threadedtests.cpp
@@ -187,7 +187,7 @@ namespace ThreadedTests {
Lock::DBRead x(&lockState, "local");
}
{
- Lock::DBWrite x(&lockState, "local");
+ Lock::DBLock x(&lockState, "local", newlm::MODE_X);
// No actual writing here, so no WriteUnitOfWork
if( sometimes ) {
Lock::TempRelease t(&lockState);
@@ -199,11 +199,11 @@ namespace ThreadedTests {
}
{
- Lock::DBWrite x(&lockState, "admin");
+ Lock::DBLock x(&lockState, "admin", newlm::MODE_X);
}
}
else if( q == 3 ) {
- Lock::DBWrite x(&lockState, "foo");
+ Lock::DBLock x(&lockState, "foo", newlm::MODE_X);
Lock::DBRead y(&lockState, "admin");
}
else if( q == 4 ) {
@@ -211,7 +211,7 @@ namespace ThreadedTests {
Lock::DBRead y(&lockState, "admin");
}
else {
- Lock::DBWrite w(&lockState, "foo");
+ Lock::DBLock w(&lockState, "foo", newlm::MODE_X);
{
Lock::TempRelease t(&lockState);