Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-3526: when a collection is renamed, its counters are kept in m…

…ap, 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)
  • Loading branch information...
commit 62993481e9c9f1edf0448eccb78a24fdfb890a7d 1 parent 1695591
@agirbal agirbal authored
View
2  db/cloner.cpp
@@ -671,6 +671,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;
}
}
View
13 db/namespace.cpp
@@ -604,6 +604,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();
@@ -657,7 +668,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 );
View
1  db/namespace.h
@@ -454,6 +454,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);
/**
* @return a cursor interface to the query optimizer. The implementation may
View
1  db/pdfile.cpp
@@ -869,6 +869,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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.