summaryrefslogtreecommitdiff
path: root/src/mongo/db/range_deleter.h
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-06-06 11:50:52 -0400
committerRandolph Tan <randolph@10gen.com>2014-06-16 13:27:23 -0400
commit0fd5d7a29ccc7c15c6e7fb2126d347f5996cf13f (patch)
tree0cea70e2eb2c9c9192a3043698cf40e56efc8493 /src/mongo/db/range_deleter.h
parent36d49e00d13b0dd083db75cbc14404b3f823a5a7 (diff)
downloadmongo-0fd5d7a29ccc7c15c6e7fb2126d347f5996cf13f.tar.gz
SERVER-13648 better stats from migration cleanup
Log waiting cursor ids and add serverStatus section
Diffstat (limited to 'src/mongo/db/range_deleter.h')
-rw-r--r--src/mongo/db/range_deleter.h98
1 files changed, 88 insertions, 10 deletions
diff --git a/src/mongo/db/range_deleter.h b/src/mongo/db/range_deleter.h
index 1471bb883b6..d2f41e928a0 100644
--- a/src/mongo/db/range_deleter.h
+++ b/src/mongo/db/range_deleter.h
@@ -32,6 +32,7 @@
#include <deque>
#include <set>
#include <string>
+#include <vector>
#include "mongo/base/disallow_copying.h"
#include "mongo/base/string_data.h"
@@ -40,12 +41,14 @@
#include "mongo/db/operation_context.h"
#include "mongo/util/concurrency/mutex.h"
#include "mongo/util/concurrency/synchronization.h"
+#include "mongo/util/time_support.h"
namespace mongo {
struct RangeDeleterEnv;
- class RangeDeleterStats;
class OperationContext;
+ struct RangeDeleteEntry;
+ struct DeleteJobStats;
/**
* Class for deleting documents for a given namespace and range. It contains a queue of
@@ -181,7 +184,12 @@ namespace mongo {
// Introspection methods
//
- const RangeDeleterStats* getStats() const;
+ // Note: original contents of stats will be cleared. Caller owns the returned stats.
+ void getStatsHistory(std::vector<DeleteJobStats*>* stats) const;
+
+ size_t getTotalDeletes() const;
+ size_t getPendingDeletes() const;
+ size_t getDeletesInProgress() const;
//
// Methods meant to be only used for testing. Should be treated like private
@@ -192,7 +200,10 @@ namespace mongo {
BSONObj toBSON() const;
private:
- struct RangeDeleteEntry;
+ // Ownership is transferred to here.
+ void recordDelStats(DeleteJobStats* newStat);
+
+
struct NSMinMax;
struct NSMinMaxCmp {
@@ -267,8 +278,69 @@ namespace mongo {
// deleteNow life cycle: deleteNow stack variable
NSMinMaxSet _blackList;
- // Keeps track of counters regarding each of the queues.
- scoped_ptr<RangeDeleterStats> _stats;
+ // Keeps track of number of tasks that are in progress, including the inline deletes.
+ size_t _deletesInProgress;
+
+ // Protects _statsHistory
+ mutable mutex _statsHistoryMutex;
+ std::deque<DeleteJobStats*> _statsHistory;
+ };
+
+
+ /**
+ * Simple class for storing statistics for the RangeDeleter.
+ */
+ struct DeleteJobStats {
+ Date_t queueStartTS;
+ Date_t queueEndTS;
+ Date_t deleteStartTS;
+ Date_t deleteEndTS;
+ Date_t waitForReplStartTS;
+ Date_t waitForReplEndTS;
+
+ long long int deletedDocCount;
+
+ DeleteJobStats(): deletedDocCount(0) {
+ }
+ };
+
+ struct RangeDeleteEntry {
+ RangeDeleteEntry(const std::string& ns,
+ const BSONObj& min,
+ const BSONObj& max,
+ const BSONObj& shardKey,
+ bool secondaryThrottle);
+
+ const std::string ns;
+
+ // Inclusive lower range.
+ const BSONObj min;
+
+ // Exclusive upper range.
+ const BSONObj max;
+
+ // The key pattern of the index the range refers to.
+ // This is relevant especially with special indexes types
+ // like hash indexes.
+ const BSONObj shardKeyPattern;
+
+ const bool secondaryThrottle;
+
+ // Sets of cursors to wait to close until this can be ready
+ // for deletion.
+ std::set<CursorId> cursorsToWait;
+
+ // Not owned here.
+ // Important invariant: Can only be set and used by one thread.
+ Notification* notifyDone;
+
+ // Time since the last time we reported this object.
+ Date_t timeSinceLastLog;
+
+ DeleteJobStats stats;
+
+ // For debugging only
+ BSONObj toBSON() const;
};
/**
@@ -288,14 +360,20 @@ namespace mongo {
* Must not throw Exceptions.
*/
virtual bool deleteRange(OperationContext* txn,
- const StringData& ns,
- const BSONObj& inclusiveLower,
- const BSONObj& exclusiveUpper,
- const BSONObj& shardKeyPattern,
- bool secondaryThrottle,
+ const RangeDeleteEntry& taskDetails,
+ long long int* deletedDocs,
+ ReplTime* lastOp,
std::string* errMsg) = 0;
/**
+ * Returns true if was ops till lastOp were replicated.
+ */
+ virtual bool waitForReplication(ReplTime lastOp,
+ const BSONObj& writeConcern,
+ long long int timeoutSecs,
+ std::string* errMsg) = 0;
+
+ /**
* Gets the list of open cursors on a given namespace. The openCursors is an
* output parameter that will contain all the cursors open after this is called.
* Assume that openCursors is empty when passed in.