diff options
author | agirbal <antoine@10gen.com> | 2011-08-03 15:00:02 -0700 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-08-04 15:11:30 -0400 |
commit | 2290dcc14e8acb3db3f4efbf2d6b095397137d23 (patch) | |
tree | 08dfed7d6b6e721e47014d9a82c80bb4e9f2c5c1 | |
parent | fba78d46345423318b9eb08bcc51c733e6dc0c5e (diff) | |
download | mongo-2290dcc14e8acb3db3f4efbf2d6b095397137d23.tar.gz |
SERVER-3526: when a collection is renamed, its counters are kept in map, which can increase memory over time (e.g. with M/R)
SERVER-3527: when a collection is dropped, the transient NS details are kept in map, which can increase memory over time (e.g. with M/R)
-rw-r--r-- | db/cloner.cpp | 2 | ||||
-rw-r--r-- | db/namespace.cpp | 13 | ||||
-rw-r--r-- | db/namespace.h | 1 | ||||
-rw-r--r-- | db/pdfile.cpp | 1 |
4 files changed, 16 insertions, 1 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp index fe57463a493..ec5ba994493 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -624,6 +624,8 @@ namespace mongo { nsToDatabase( target.c_str(), to ); if ( strcmp( from, to ) == 0 ) { renameNamespace( source.c_str(), target.c_str() ); + // make sure we drop counters etc + Top::global.collectionDropped( source ); return true; } } diff --git a/db/namespace.cpp b/db/namespace.cpp index fcdaee26946..0cb0e7495ac 100644 --- a/db/namespace.cpp +++ b/db/namespace.cpp @@ -598,6 +598,17 @@ namespace mongo { } } + void NamespaceDetailsTransient::eraseForPrefix(const char *prefix) { + assertInWriteLock(); + vector< string > found; + for( ouriter i = _map.begin(); i != _map.end(); ++i ) + if ( strncmp( i->first.c_str(), prefix, strlen( prefix ) ) == 0 ) + found.push_back( i->first ); + for( vector< string >::iterator i = found.begin(); i != found.end(); ++i ) { + _map.erase(*i); + } + } + void NamespaceDetailsTransient::computeIndexKeys() { _keysComputed = true; _indexKeys.clear(); @@ -648,7 +659,7 @@ namespace mongo { // index details across commands are in cursors and nsd // transient (including query cache) so clear these. ClientCursor::invalidate( from ); - NamespaceDetailsTransient::clearForPrefix( from ); + NamespaceDetailsTransient::eraseForPrefix( from ); NamespaceDetails *details = ni->details( from ); ni->add_ns( to, *details ); diff --git a/db/namespace.h b/db/namespace.h index 4ec1eddabe1..ef3d04e8acf 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -425,6 +425,7 @@ namespace mongo { Can be useful as index namespaces share the same start as the regular collection. SLOW - sequential scan of all NamespaceDetailsTransient objects */ static void clearForPrefix(const char *prefix); + static void eraseForPrefix(const char *prefix); /* indexKeys() cache ---------------------------------------------------- */ /* assumed to be in write lock for this */ diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 663ae05534c..2aedfd44c4c 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -806,6 +806,7 @@ namespace mongo { result.append("ns", name.c_str()); ClientCursor::invalidate(name.c_str()); Top::global.collectionDropped( name ); + NamespaceDetailsTransient::eraseForPrefix( name.c_str() ); dropNS(name); } |