Skip to content

Commit

Permalink
SERVER-1849 allow recreating a recently dropped collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Lerner committed Sep 27, 2010
1 parent ae8f18e commit d260bd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions jstests/sharding/shard3.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ assert.eq( 0 , secondary.count() , "s count after drop" )
primary.save( { num : 1 } );
secondary.save( { num : 4 } );

assert.eq( 1 , primary.count() , "p count after drop adn save" )
assert.eq( 1 , secondary.count() , "s count after drop save " )
assert.eq( 1 , primary.count() , "p count after drop and save" )
assert.eq( 1 , secondary.count() , "s count after drop and save " )


print("*** makes sure that sharding knows where things live" );
Expand Down
2 changes: 0 additions & 2 deletions s/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,6 @@ namespace mongo {
_chunkMap.clear();
_chunkRanges.clear();
_shards.clear();


// delete data from mongod
for ( set<Shard>::iterator i=seen.begin(); i!=seen.end(); i++ ){
Expand Down Expand Up @@ -872,7 +871,6 @@ namespace mongo {
conn.done();
}


log(1) << "ChunkManager::drop : " << _ns << "\t DONE" << endl;
configServer.logChange( "dropCollection" , _ns , BSONObj() );
}
Expand Down
7 changes: 5 additions & 2 deletions s/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace mongo {
void DBConfig::CollectionInfo::shard( DBConfig * db , const string& ns , const ShardKeyPattern& key , bool unique ){
_cm.reset( new ChunkManager( db, ns , key , unique ) );
_dirty = true;
_dropped = false;
}

void DBConfig::CollectionInfo::unshard(){
Expand All @@ -81,10 +82,12 @@ namespace mongo {
_cm->getInfo( val );

conn->update( ShardNS::collection , key , val.obj() , true );
string err = conn->getLastError();
uassert( 13473 , (string)"failed to save collection (" + ns + "): " + err , err.size() == 0 );

_dirty = false;
}


bool DBConfig::isSharded( const string& ns ){
if ( ! _shardingEnabled )
return false;
Expand Down Expand Up @@ -124,7 +127,7 @@ namespace mongo {
scoped_lock lk( _lock );

CollectionInfo& ci = _collections[ns];
uassert( 8043 , "already sharded" , ! ci.isSharded() );
uassert( 8043 , "collection already sharded" , ! ci.isSharded() );

log() << "enable sharding on: " << ns << " with shard key: " << fieldsAndOrder << endl;

Expand Down

0 comments on commit d260bd6

Please sign in to comment.