diff options
Diffstat (limited to 'src/mongo/db/namespace_details.cpp')
-rw-r--r-- | src/mongo/db/namespace_details.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/mongo/db/namespace_details.cpp b/src/mongo/db/namespace_details.cpp index bd38b666f3e..931f44c8745 100644 --- a/src/mongo/db/namespace_details.cpp +++ b/src/mongo/db/namespace_details.cpp @@ -120,6 +120,28 @@ namespace mongo { } #endif + void NamespaceDetails::onLoad(const Namespace& k) { + + if( k.isExtra() ) { + /* overflow storage for indexes - so don't treat as a NamespaceDetails object. */ + return; + } + + if( indexBuildInProgress ) { + verify( Lock::isW() ); // TODO(erh) should this be per db? + if( indexBuildInProgress ) { + log() << "indexBuildInProgress was " << indexBuildInProgress << " for " << k << ", indicating an abnormal db shutdown" << endl; + getDur().writingInt( indexBuildInProgress ) = 0; + } + } + } + + static void namespaceOnLoadCallback(const Namespace& k, NamespaceDetails& v) { + v.onLoad(k); + } + + bool checkNsFilesOnLoad = true; + NOINLINE_DECL void NamespaceIndex::_init() { verify( !ht ); @@ -172,6 +194,8 @@ namespace mongo { verify( len <= 0x7fffffff ); ht = new HashTable<Namespace,NamespaceDetails>(p, (int) len, "namespace index"); + if( checkNsFilesOnLoad ) + ht->iterAll(namespaceOnLoadCallback); } static void namespaceGetNamespacesCallback( const Namespace& k , NamespaceDetails& v , void * extra ) { @@ -499,7 +523,8 @@ namespace mongo { NamespaceDetailsTransient::get(thisns).clearQueryCache(); } - IndexDetails& NamespaceDetails::getNextIndexDetails(const char* thisns) { + /* you MUST call when adding an index. see pdfile.cpp */ + IndexDetails& NamespaceDetails::addIndex(const char *thisns, bool resetTransient) { IndexDetails *id; try { id = &idx(nIndexes,true); @@ -508,13 +533,11 @@ namespace mongo { allocExtra(thisns, nIndexes); id = &idx(nIndexes,false); } - return *id; - } - /* you MUST call when adding an index. see pdfile.cpp */ - void NamespaceDetails::addIndex(const char* thisns) { (*getDur().writing(&nIndexes))++; - NamespaceDetailsTransient::get(thisns).addedIndex(); + if ( resetTransient ) + NamespaceDetailsTransient::get(thisns).addedIndex(); + return *id; } // must be called when renaming a NS to fix up extra |