diff options
author | Alberto Lerner <alerner@10gen.com> | 2010-09-25 07:21:25 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2010-09-27 08:36:25 -0400 |
commit | d260bd608659d0a4610cdcec3ca9e355b18bf9b2 (patch) | |
tree | 80c404db4acfc9319b6c501c4c4135e6b867ba24 | |
parent | ae8f18e9216e42aa2eca9fb837908f4c2af7ce6d (diff) | |
download | mongo-d260bd608659d0a4610cdcec3ca9e355b18bf9b2.tar.gz |
SERVER-1849 allow recreating a recently dropped collection
-rw-r--r-- | jstests/sharding/shard3.js | 4 | ||||
-rw-r--r-- | s/chunk.cpp | 2 | ||||
-rw-r--r-- | s/config.cpp | 7 |
3 files changed, 7 insertions, 6 deletions
diff --git a/jstests/sharding/shard3.js b/jstests/sharding/shard3.js index 86faedce5ff..e57dc1e5bd5 100644 --- a/jstests/sharding/shard3.js +++ b/jstests/sharding/shard3.js @@ -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" ); diff --git a/s/chunk.cpp b/s/chunk.cpp index cf1f9929c04..87d7747c6e8 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -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++ ){ @@ -872,7 +871,6 @@ namespace mongo { conn.done(); } - log(1) << "ChunkManager::drop : " << _ns << "\t DONE" << endl; configServer.logChange( "dropCollection" , _ns , BSONObj() ); } diff --git a/s/config.cpp b/s/config.cpp index e1016a013b1..1ad15d52c29 100644 --- a/s/config.cpp +++ b/s/config.cpp @@ -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(){ @@ -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; @@ -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; |