summaryrefslogtreecommitdiff
path: root/src/mongo/db/ttl.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-01-11 08:26:57 -0500
committerEliot Horowitz <eliot@10gen.com>2014-01-12 23:39:41 -0500
commitee5bf211dd5db16a8fd8e40d0fadae4114014b4b (patch)
tree68144e53fb0f4d651be5ae4fc6ab76ffab58a83b /src/mongo/db/ttl.cpp
parent0e1d3ea041f92397ef896574b00b51930d32fb1a (diff)
downloadmongo-ee5bf211dd5db16a8fd8e40d0fadae4114014b4b.tar.gz
SERVER-11628: make sure ttl index is complete before deleting documents
Diffstat (limited to 'src/mongo/db/ttl.cpp')
-rw-r--r--src/mongo/db/ttl.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index 15d5dbe1658..3cf65afda99 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -105,26 +105,36 @@ namespace mongo {
b.appendDate( "$lt" , curTimeMillis64() - ( 1000 * idx[secondsExpireField].numberLong() ) );
query = BSON( key.firstElement().fieldName() << b.obj() );
}
-
+
LOG(1) << "TTL: " << key << " \t " << query << endl;
-
+
long long n = 0;
{
string ns = idx["ns"].String();
Client::WriteContext ctx( ns );
- NamespaceDetails* nsd = nsdetails( ns );
- if ( ! nsd ) {
+ Collection* collection = ctx.ctx().db()->getCollection( ns );
+ if ( !collection ) {
// collection was dropped
continue;
}
+
+ NamespaceDetails* nsd = collection->details();
if ( nsd->setUserFlag( NamespaceDetails::Flag_UsePowerOf2Sizes ) ) {
+ // TODO: wish there was a cleaner way to do this
nsd->syncUserFlags( ns );
}
+
// only do deletes if on master
if ( ! isMaster ) {
continue;
}
+ if ( collection->getIndexCatalog()->findIndexByKeyPattern( key ) == NULL ) {
+ // index not finished yet
+ LOG(1) << " skipping index because not finished";
+ continue;
+ }
+
n = deleteObjects( ns , query , false , true );
ttlDeletedDocuments.increment( n );
}