summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/collection.cpp5
-rw-r--r--src/mongo/db/catalog/collection.h3
-rw-r--r--src/mongo/db/commands/validate.cpp5
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_transaction.cpp13
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_transaction.h5
-rw-r--r--src/mongo/db/storage/transaction.h16
-rw-r--r--src/mongo/db/structure/record_store.h3
-rw-r--r--src/mongo/db/structure/record_store_v1_base.cpp8
-rw-r--r--src/mongo/db/structure/record_store_v1_base.h3
-rw-r--r--src/mongo/db/structure/record_store_v1_simple.cpp5
10 files changed, 53 insertions, 13 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index 64a9917b852..bc03f568704 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -575,11 +575,12 @@ namespace mongo {
};
}
- Status Collection::validate( bool full, bool scanData,
+ Status Collection::validate( TransactionExperiment* txn,
+ bool full, bool scanData,
ValidateResults* results, BSONObjBuilder* output ){
MyValidateAdaptor adaptor;
- Status status = _recordStore->validate( full, scanData, &adaptor, results, output );
+ Status status = _recordStore->validate( txn, full, scanData, &adaptor, results, output );
if ( !status.isOK() )
return status;
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index be9d1f0e386..9c4ed27a540 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -224,7 +224,8 @@ namespace mongo {
* OK will be returned even if corruption is found
* deatils will be in result
*/
- Status validate( bool full, bool scanData,
+ Status validate( TransactionExperiment* txn,
+ bool full, bool scanData,
ValidateResults* results, BSONObjBuilder* output );
/**
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp
index bb08fb4f882..b7148a00c01 100644
--- a/src/mongo/db/commands/validate.cpp
+++ b/src/mongo/db/commands/validate.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/runner.h"
#include "mongo/db/storage/extent.h"
+#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/db/catalog/collection.h"
namespace mongo {
@@ -76,6 +77,8 @@ namespace mongo {
}
Client::ReadContext ctx(ns_string.ns());
+ DurTransaction txn;
+
Database* db = ctx.ctx().db();
if ( !db ) {
errmsg = "database not found";
@@ -91,7 +94,7 @@ namespace mongo {
result.append( "ns", ns );
ValidateResults results;
- Status status = collection->validate( full, scanData, &results, &result );
+ Status status = collection->validate( &txn, full, scanData, &results, &result );
if ( !status.isOK() )
return appendCommandStatus( result, status );
diff --git a/src/mongo/db/storage/mmap_v1/dur_transaction.cpp b/src/mongo/db/storage/mmap_v1/dur_transaction.cpp
index 2e416bd9708..f235c6dad21 100644
--- a/src/mongo/db/storage/mmap_v1/dur_transaction.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_transaction.cpp
@@ -28,6 +28,7 @@
#include "mongo/db/storage/mmap_v1/dur_transaction.h"
+#include "mongo/db/kill_current_op.h"
#include "mongo/db/storage/mmap_v1/dur.h"
namespace mongo {
@@ -44,4 +45,16 @@ namespace mongo {
return getDur().writingPtr(data, len);
}
+ void DurTransaction::checkForInterrupt() const {
+ killCurrentOp.checkForInterrupt();
+ }
+
+ Status DurTransaction::checkForInterruptNoAssert() const {
+ const char* killed = killCurrentOp.checkForInterruptNoAssert();
+ if ( !killed || !killed[0] )
+ return Status::OK();
+
+ return Status( ErrorCodes::Interrupted, killed );
+ }
+
} // namespace mongo
diff --git a/src/mongo/db/storage/mmap_v1/dur_transaction.h b/src/mongo/db/storage/mmap_v1/dur_transaction.h
index 55412e83bb6..66a8c015144 100644
--- a/src/mongo/db/storage/mmap_v1/dur_transaction.h
+++ b/src/mongo/db/storage/mmap_v1/dur_transaction.h
@@ -46,6 +46,11 @@ namespace mongo {
virtual bool isCommitNeeded() const;
virtual void* writingPtr(void* data, size_t len);
+
+ virtual void checkForInterrupt() const;
+
+ virtual Status checkForInterruptNoAssert() const;
+
};
} // namespace mongo
diff --git a/src/mongo/db/storage/transaction.h b/src/mongo/db/storage/transaction.h
index 2799ae2df09..6846331e7a7 100644
--- a/src/mongo/db/storage/transaction.h
+++ b/src/mongo/db/storage/transaction.h
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include "mongo/base/disallow_copying.h"
+#include "mongo/base/status.h"
namespace mongo {
@@ -42,6 +43,21 @@ namespace mongo {
public:
virtual ~TransactionExperiment() { }
+ // --- operation level info? ---
+
+ /**
+ * throws an exception if the operation is interrupted
+ */
+ virtual void checkForInterrupt() const = 0;
+
+ /**
+ * @return Status::OK() if not interrupted
+ * otherwise returns reasons
+ */
+ virtual Status checkForInterruptNoAssert() const = 0;
+
+ // --- write unit of work methods ---
+
/**
* Commit if required. May take a long time. Returns true if committed.
*/
diff --git a/src/mongo/db/structure/record_store.h b/src/mongo/db/structure/record_store.h
index 4aece12f0fa..0282e52dc59 100644
--- a/src/mongo/db/structure/record_store.h
+++ b/src/mongo/db/structure/record_store.h
@@ -155,7 +155,8 @@ namespace mongo {
* OK will be returned even if corruption is found
* deatils will be in result
*/
- virtual Status validate( bool full, bool scanData,
+ virtual Status validate( TransactionExperiment* txn,
+ bool full, bool scanData,
ValidateAdaptor* adaptor,
ValidateResults* results, BSONObjBuilder* output ) const = 0;
diff --git a/src/mongo/db/structure/record_store_v1_base.cpp b/src/mongo/db/structure/record_store_v1_base.cpp
index d220d483195..e38d5cc82c1 100644
--- a/src/mongo/db/structure/record_store_v1_base.cpp
+++ b/src/mongo/db/structure/record_store_v1_base.cpp
@@ -31,7 +31,6 @@
#include "mongo/db/structure/record_store_v1_base.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/kill_current_op.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/storage/extent_manager.h"
#include "mongo/db/storage/record.h"
@@ -305,7 +304,8 @@ namespace mongo {
addDeletedRec(txn, emptyLoc);
}
- Status RecordStoreV1Base::validate( bool full, bool scanData,
+ Status RecordStoreV1Base::validate( TransactionExperiment* txn,
+ bool full, bool scanData,
ValidateAdaptor* adaptor,
ValidateResults* results, BSONObjBuilder* output ) const {
@@ -380,7 +380,7 @@ namespace mongo {
}
extentDiskLoc = nextDiskLoc;
extentCount++;
- killCurrentOp.checkForInterrupt();
+ txn->checkForInterrupt();
}
}
catch (const DBException& e) {
@@ -576,7 +576,7 @@ namespace mongo {
delSize += d->lengthWithHeaders();
loc = d->nextDeleted();
k++;
- killCurrentOp.checkForInterrupt();
+ txn->checkForInterrupt();
}
delBucketSizes << k;
}
diff --git a/src/mongo/db/structure/record_store_v1_base.h b/src/mongo/db/structure/record_store_v1_base.h
index c066446835a..63eed52eb17 100644
--- a/src/mongo/db/structure/record_store_v1_base.h
+++ b/src/mongo/db/structure/record_store_v1_base.h
@@ -124,7 +124,8 @@ namespace mongo {
void increaseStorageSize( TransactionExperiment* txn, int size, int quotaMax );
- virtual Status validate( bool full, bool scanData,
+ virtual Status validate( TransactionExperiment* txn,
+ bool full, bool scanData,
ValidateAdaptor* adaptor,
ValidateResults* results, BSONObjBuilder* output ) const;
diff --git a/src/mongo/db/structure/record_store_v1_simple.cpp b/src/mongo/db/structure/record_store_v1_simple.cpp
index 32a5729b72f..85ec3bff441 100644
--- a/src/mongo/db/structure/record_store_v1_simple.cpp
+++ b/src/mongo/db/structure/record_store_v1_simple.cpp
@@ -35,7 +35,6 @@
#include "mongo/db/client.h"
#include "mongo/db/commands/server_status.h"
#include "mongo/db/curop.h"
-#include "mongo/db/kill_current_op.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/storage/extent_manager.h"
#include "mongo/db/storage/record.h"
@@ -422,13 +421,13 @@ namespace mongo {
// remove the old records (orphan them) periodically so our commit block doesn't get too large
bool stopping = false;
- RARELY stopping = *killCurrentOp.checkForInterruptNoAssert() != 0;
+ RARELY stopping = !txn->checkForInterruptNoAssert().isOK();
if( stopping || txn->isCommitNeeded() ) {
*txn->writing(&e->firstRecord) = L;
Record *r = recordFor(L);
txn->writingInt(r->prevOfs()) = DiskLoc::NullOfs;
txn->commitIfNeeded();
- killCurrentOp.checkForInterrupt();
+ txn->checkForInterrupt();
}
}
} // if !L.isNull()