summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/rollbacktests.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2014-11-20 14:26:43 -0500
committerGeert Bosch <geert@mongodb.com>2014-11-21 13:18:53 -0500
commite7f6c56327afa51847a95d9d5bc6399209856c10 (patch)
tree93a6f8b98d13ff81bd21a2ffc9f312e4ff662123 /src/mongo/dbtests/rollbacktests.cpp
parente5644e2ca12a60df677cb8e8dfc70f19a9423b0a (diff)
downloadmongo-e7f6c56327afa51847a95d9d5bc6399209856c10.tar.gz
SERVER-16192: Add ScopedTransaction to automatically commitAndRestart()
Diffstat (limited to 'src/mongo/dbtests/rollbacktests.cpp')
-rw-r--r--src/mongo/dbtests/rollbacktests.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp
index 793ad9389e8..684f824b4a1 100644
--- a/src/mongo/dbtests/rollbacktests.cpp
+++ b/src/mongo/dbtests/rollbacktests.cpp
@@ -46,6 +46,7 @@ namespace RollbackTests {
namespace {
void dropDatabase( OperationContext* txn, const NamespaceString& nss ) {
+ ScopedTransaction transaction(txn, MODE_X);
Lock::GlobalWrite globalWriteLock( txn->lockState() );
Database* db = dbHolder().get( txn, nss.db() );
@@ -60,6 +61,7 @@ namespace {
return std::find( names.begin(), names.end(), ns ) != names.end();
}
void createCollection( OperationContext* txn, const NamespaceString& nss ) {
+ ScopedTransaction transaction( txn, MODE_IX );
Lock::DBLock dbXLock( txn->lockState(), nss.db(), MODE_X );
Client::Context ctx( txn, nss.ns() );
{
@@ -155,6 +157,7 @@ namespace {
NamespaceString nss( ns );
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, ns );
{
@@ -184,6 +187,7 @@ namespace {
NamespaceString nss( ns );
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, ns );
{
@@ -225,6 +229,7 @@ namespace {
dropDatabase( &txn, source );
dropDatabase( &txn, target );
+ ScopedTransaction transaction(&txn, MODE_X);
Lock::GlobalWrite globalWriteLock( txn.lockState() );
Client::Context ctx( &txn, source );
@@ -272,6 +277,7 @@ namespace {
dropDatabase( &txn, source );
dropDatabase( &txn, target );
+ ScopedTransaction transaction(&txn, MODE_X);
Lock::GlobalWrite globalWriteLock( txn.lockState() );
Client::Context ctx( &txn, source );
@@ -332,6 +338,7 @@ namespace {
OperationContextImpl txn;
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, nss );
@@ -382,6 +389,7 @@ namespace {
OperationContextImpl txn;
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, nss );
@@ -416,6 +424,7 @@ namespace {
OperationContextImpl txn;
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, nss );
@@ -467,6 +476,7 @@ namespace {
dropDatabase( &txn, nss );
createCollection( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbIXLock( txn.lockState(), nss.db(), MODE_IX );
Lock::CollectionLock collXLock( txn.lockState(), ns, MODE_X );
@@ -509,6 +519,7 @@ namespace {
dropDatabase( &txn, nss );
createCollection( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbIXLock( txn.lockState(), nss.db(), MODE_IX );
Lock::CollectionLock collXLock( txn.lockState(), ns, MODE_X );
@@ -563,6 +574,7 @@ namespace {
dropDatabase( &txn, nss );
createCollection( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbIXLock( txn.lockState(), nss.db(), MODE_IX );
Lock::CollectionLock collXLock( txn.lockState(), ns, MODE_X );
@@ -607,6 +619,7 @@ namespace {
dropDatabase( &txn, nss );
createCollection( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbIXLock( txn.lockState(), nss.db(), MODE_IX );
Lock::CollectionLock collXLock( txn.lockState(), ns, MODE_X );
@@ -669,6 +682,7 @@ namespace {
OperationContextImpl txn;
NamespaceString nss( ns );
dropDatabase( &txn, nss );
+ ScopedTransaction transaction(&txn, MODE_IX);
Lock::DBLock dbXLock( txn.lockState(), nss.db(), MODE_X );
Client::Context ctx( &txn, nss.ns() );
string idxNameA = "indexA";