summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-04-04 12:51:32 -0400
committerEliot Horowitz <eliot@10gen.com>2014-04-04 15:03:56 -0400
commit1d50eac6f00016a3366827df2e851531f8c56d3b (patch)
tree10a67eb9f8036c9e8fbace43fc780f7919be3449 /src
parent56136a9d8f165fe9ec74bb4928404206ce63610f (diff)
downloadmongo-1d50eac6f00016a3366827df2e851531f8c56d3b.tar.gz
SERVER-13084: move ttl -> power of 2 checking into IndexCatalog
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp25
-rw-r--r--src/mongo/db/ttl.cpp17
2 files changed, 25 insertions, 17 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 1ce951a7e14..f09e6323c75 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -149,6 +149,24 @@ namespace mongo {
invariant( save == _entries.find( descriptor ) );
invariant( save == _entries.find( descriptor->indexName() ) );
+
+ // check index to see if wants us to do special things
+
+ { // power of 2
+ bool requirePowerOf2 = false;
+ if ( IndexNames::findPluginName( descriptor->keyPattern() ) == IndexNames::TEXT )
+ requirePowerOf2 = true;
+
+ if ( descriptor->getInfoElement("expireAfterSeconds").isNumber() )
+ requirePowerOf2 = true;
+
+ if ( requirePowerOf2 ) {
+ if ( _details->setUserFlag(NamespaceDetails::Flag_UsePowerOf2Sizes) ) {
+ _details->syncUserFlags( _collection->ns().ns() );
+ }
+ }
+ }
+
return save;
}
@@ -342,13 +360,6 @@ namespace mongo {
int idxNo = _details->_catalogFindIndexByName( idxName, true );
invariant( idxNo < numIndexesReady() );
- // some special cases stuff
- if ( pluginName == IndexNames::TEXT ) {
- if ( _details->setUserFlag(NamespaceDetails::Flag_UsePowerOf2Sizes) ) {
- _details->syncUserFlags( _collection->ns().ns() );
- }
- }
-
return Status::OK();
}
catch ( const AssertionException& exc ) {
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index c5459bf3410..87217718c57 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -67,7 +67,9 @@ namespace mongo {
void doTTLForDB( const string& dbName ) {
- bool isMaster = isMasterNs( dbName.c_str() );
+ if ( !isMasterNs( dbName.c_str() ) )
+ return;
+
vector<BSONObj> indexes;
{
auto_ptr<DBClientCursor> cursor =
@@ -119,15 +121,10 @@ namespace mongo {
continue;
}
- NamespaceDetails* nsd = collection->detailsWritable();
- 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 ( !isMasterNs( dbName.c_str() ) ) {
+ // we've stepped down since we started this function,
+ // so we should stop working as we only do deletes on the primary
+ break;
}
if ( collection->getIndexCatalog()->findIndexByKeyPattern( key ) == NULL ) {