0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

remove temp collection code

This commit is contained in:
Eliot Horowitz 2010-12-17 00:22:20 -05:00
parent f2a61623cd
commit e634287abf
5 changed files with 4 additions and 80 deletions

View File

@ -81,56 +81,6 @@ namespace mongo {
delete _curOp;
}
void Client::_dropns( const string& ns ){
Top::global.collectionDropped( ns );
dblock l;
Client::Context ctx( ns );
if ( ! nsdetails( ns.c_str() ) )
return;
try {
string err;
BSONObjBuilder b;
dropCollection( ns , err , b );
}
catch ( ... ){
warning() << "error dropping temp collection: " << ns << endl;
}
}
void Client::_invalidateDB( const string& db ) {
assert( db.find( '.' ) == string::npos );
set<string>::iterator min = _tempCollections.lower_bound( db + "." );
set<string>::iterator max = _tempCollections.lower_bound( db + "|" );
_tempCollections.erase( min , max );
}
void Client::invalidateDB(const string& db) {
scoped_lock bl(clientsMutex);
for ( set<Client*>::iterator i = clients.begin(); i!=clients.end(); i++ ){
Client* cli = *i;
cli->_invalidateDB(db);
}
}
void Client::invalidateNS( const string& ns ){
scoped_lock bl(clientsMutex);
for ( set<Client*>::iterator i = clients.begin(); i!=clients.end(); i++ ){
Client* cli = *i;
cli->_tempCollections.erase( ns );
}
}
void Client::addTempCollection( const string& ns ) {
_tempCollections.insert( ns );
}
bool Client::shutdown(){
_shutdown = true;
if ( inShutdown() )
@ -143,17 +93,7 @@ namespace mongo {
}
}
bool didAnything = false;
if ( _tempCollections.size() ){
didAnything = true;
for ( set<string>::iterator i = _tempCollections.begin(); i!=_tempCollections.end(); i++ ){
_dropns( *i );
}
_tempCollections.clear();
}
return didAnything;
return false;
}
BSONObj CachedBSONObj::_tooBig = fromjson("{\"$msg\":\"query not recording (too large)\"}");

View File

@ -158,12 +158,9 @@ namespace mongo {
}; // class Client::Context
private:
void _dropns( const string& ns );
CurOp * _curOp;
Context * _context;
bool _shutdown;
set<string> _tempCollections;
const char *_desc;
bool _god;
AuthenticationInfo _ai;
@ -185,14 +182,9 @@ namespace mongo {
Database* database() { return _context ? _context->db() : 0; }
const char *ns() const { return _context->ns(); }
const char *desc() const { return _desc; }
void addTempCollection( const string& ns );
void _invalidateDB(const string& db);
void setLastOp( ReplTime op ) { _lastOp = op; }
ReplTime getLastOp() const { return _lastOp; }
static void invalidateDB(const string& db);
static void invalidateNS( const string& ns );
/* report what the last operation was. used by getlasterror */
void appendLastOp( BSONObjBuilder& b ) {
if( theReplSet ) {

View File

@ -174,7 +174,7 @@ namespace mongo {
_reduce( x , key , endSizeEstimate );
}
Config::Config( const string& _dbname , const BSONObj& cmdObj , bool markAsTemp ){
Config::Config( const string& _dbname , const BSONObj& cmdObj ){
dbname = _dbname;
ns = dbname + "." + cmdObj.firstElement().valuestr();
@ -223,9 +223,6 @@ namespace mongo {
incLong = tempLong + "_inc";
//if ( markAsTemp )
cc().addTempCollection( tempLong );
finalLong = dbname + "." + finalShort;
}
@ -791,7 +788,7 @@ namespace mongo {
bool run(const string& dbname , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
string shardedOutputCollection = cmdObj["shardedOutputCollection"].valuestrsafe();
Config config( dbname , cmdObj.firstElement().embeddedObjectUserCheck() , false );
Config config( dbname , cmdObj.firstElement().embeddedObjectUserCheck() );
config.incLong = config.tempLong;
set<ServerAndQuery> servers;

View File

@ -146,7 +146,7 @@ namespace mongo {
*/
class Config {
public:
Config( const string& _dbname , const BSONObj& cmdObj , bool markAsTemp = true );
Config( const string& _dbname , const BSONObj& cmdObj );
string dbname;
string ns;

View File

@ -787,7 +787,6 @@ namespace mongo {
log(1) << "\t dropIndexes done" << endl;
result.append("ns", name.c_str());
ClientCursor::invalidate(name.c_str());
Client::invalidateNS( name );
Top::global.collectionDropped( name );
dropNS(name);
}
@ -1734,10 +1733,6 @@ namespace mongo {
BackgroundOperation::assertNoBgOpInProgForDb(d->name.c_str());
/* why is this not called all the time in closeDatabase?! seems dangerous? */
/* no path specified here - seems dangerous */
Client::invalidateDB( d->name );
Database::closeDatabase( d->name.c_str(), d->path );
d = 0; // d is now deleted
getDur().droppingDb(db);