Skip to content

Commit

Permalink
Merge branch 'v2.0' of github.com:mongodb/mongo into v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Nov 22, 2011
2 parents e9ec52c + a91919f commit c0044c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doxygenConfig
Expand Up @@ -3,7 +3,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = MongoDB
PROJECT_NUMBER = 2.0.2-rc1-pre-
PROJECT_NUMBER = 2.0.2-rc1
OUTPUT_DIRECTORY = docs/doxygen
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
Expand Down
25 changes: 23 additions & 2 deletions s/shard_version.cpp
Expand Up @@ -56,6 +56,16 @@ namespace mongo {
: _mutex( "ConnectionShardStatus" ) {
}

bool isInitialized( DBClientBase * conn ){
scoped_lock lk( _mutex );
return _init.find( conn ) != _init.end();
}

void setInitialized( DBClientBase * conn ){
scoped_lock lk( _mutex );
_init.insert( conn );
}

S getSequence( DBClientBase * conn , const string& ns ) {
scoped_lock lk( _mutex );
return _map[conn][ns];
Expand All @@ -69,13 +79,15 @@ namespace mongo {
void reset( DBClientBase * conn ) {
scoped_lock lk( _mutex );
_map.erase( conn );
_init.erase( conn );
}

// protects _map
// protects _maps
mongo::mutex _mutex;

// a map from a connection into ChunkManager's sequence number for each namespace
map<DBClientBase*, map<string,unsigned long long> > _map;
set<DBClientBase*> _init;

} connectionShardStatus;

Expand Down Expand Up @@ -133,11 +145,15 @@ namespace mongo {
LOG(2) << "initial sharding settings : " << cmd << endl;

bool ok = conn->runCommand( "admin" , cmd , result );
connectionShardStatus.setInitialized( conn );

// HACK for backwards compatibility with v1.8.x, v2.0.0 and v2.0.1
// Result is false, but will still initialize serverID and configdb
// Not master does not initialize serverID and configdb, but we ignore since if the connection is not master,
// we are not setting the shard version at all
if( ! ok && ! result["errmsg"].eoo() && ( result["errmsg"].String() == "need to specify namespace"/* 2.0.1/2 */ ||
result["errmsg"].String() == "need to speciy namespace" /* 1.8 */ ))
result["errmsg"].String() == "need to speciy namespace" /* 1.8 */ ||
result["errmsg"].String() == "not master" /* both */ ) )
{
ok = true;
}
Expand All @@ -163,6 +179,11 @@ namespace mongo {
DBClientBase* conn = getVersionable( &conn_in );
assert(conn); // errors thrown above

if( ! connectionShardStatus.isInitialized( conn ) ){
BSONObj result;
uassert( 15918, str::stream() << "cannot initialize version on shard " << conn->getServerAddress() << causedBy( result.toString() ), initShardVersion( *conn, result ) );
}

unsigned long long officialSequenceNumber = 0;

ChunkManagerPtr manager;
Expand Down
2 changes: 1 addition & 1 deletion util/version.cpp
Expand Up @@ -38,7 +38,7 @@ namespace mongo {
* 1.2.3-rc4-pre-
* If you really need to do something else you'll need to fix _versionArray()
*/
const char versionString[] = "2.0.2-rc1-pre-";
const char versionString[] = "2.0.2-rc1";

// See unit test for example outputs
static BSONArray _versionArray(const char* version){
Expand Down

0 comments on commit c0044c7

Please sign in to comment.