mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-7646 - track how many docs TTL deletes
This commit is contained in:
parent
c49f0d4343
commit
a266c93faa
@ -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() );
|
||||
assert.eq( 9 , t.count() );
|
||||
|
@ -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(); }
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user