summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/slowNightly/ttl1.js4
-rw-r--r--src/mongo/base/counter.h3
-rw-r--r--src/mongo/db/ttl.cpp18
3 files changed, 21 insertions, 4 deletions
diff --git a/jstests/slowNightly/ttl1.js b/jstests/slowNightly/ttl1.js
index fea3e7d41b4..c05000c518a 100644
--- a/jstests/slowNightly/ttl1.js
+++ b/jstests/slowNightly/ttl1.js
@@ -38,6 +38,8 @@ assert.soon(
assert.eq( 0 , t.find( { x : { $lt : new Date( now - 20000000 ) } } ).count() );
assert.eq( 12 , t.count() );
+assert.lte( 18, db.serverStatus().metrics.ttl.deletedDocuments );
+
// Part 2
t.ensureIndex( { y : 1 } , { expireAfterSeconds : 10000 } );
@@ -48,4 +50,4 @@ assert.soon(
);
assert.eq( 0 , t.find( { y : { $lt : new Date( now - 10000000 ) } } ).count() );
-assert.eq( 9 , t.count() ); \ No newline at end of file
+assert.eq( 9 , t.count() );
diff --git a/src/mongo/base/counter.h b/src/mongo/base/counter.h
index 91508c98f67..c1c69b0cdb6 100644
--- a/src/mongo/base/counter.h
+++ b/src/mongo/base/counter.h
@@ -19,13 +19,14 @@
#pragma once
#include "mongo/platform/atomic_word.h"
+#include "mongo/platform/cstdint.h"
namespace mongo {
class Counter64 {
public:
- void increment() { _counter.addAndFetch(1); }
+ void increment( uint64_t n = 1 ) { _counter.addAndFetch(n); }
long long get() const { return _counter.load(); }
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index 76aa3165de3..5673a3e92d0 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -18,15 +18,26 @@
#include "pch.h"
-#include "mongo/db/commands/fsync.h"
#include "mongo/db/ttl.h"
+
+#include "mongo/base/counter.h"
+#include "mongo/db/commands/fsync.h"
+#include "mongo/db/commands/server_status.h"
#include "mongo/db/databaseholder.h"
#include "mongo/db/instance.h"
#include "mongo/db/ops/delete.h"
-#include "mongo/util/background.h"
#include "mongo/db/replutil.h"
+#include "mongo/util/background.h"
namespace mongo {
+
+ Counter64 ttlPasses;
+ Counter64 ttlDocDeletes;
+
+ ServerStatusMetricField<Counter64> ttlPassesDisplay( "ttl.passes", false, &ttlPasses );
+ ServerStatusMetricField<Counter64> ttlDocDeletesDisplay( "ttl.deletedDocuments", false, &ttlDocDeletes );
+
+
class TTLMonitor : public BackgroundJob {
public:
@@ -94,6 +105,7 @@ namespace mongo {
}
n = deleteObjects( ns.c_str() , query , false , true );
+ ttlDocDeletes.increment( n );
}
LOG(1) << "\tTTL deleted: " << n << endl;
@@ -127,6 +139,8 @@ namespace mongo {
dbHolder().getAllShortNames( dbs );
}
+ ttlPasses.increment();
+
for ( set<string>::const_iterator i=dbs.begin(); i!=dbs.end(); ++i ) {
string db = *i;
try {