diff options
author | Greg Studer <greg@10gen.com> | 2013-05-31 14:12:54 -0400 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2013-06-04 17:57:09 -0400 |
commit | 34f701faec271c454612a8b992efbae7f9070a96 (patch) | |
tree | 8f06c46ec22ff0a5c31dbcc8b1222cf951138254 /src | |
parent | 33e8bf580ac5a573f007a0f85f66406751700c03 (diff) | |
download | mongo-34f701faec271c454612a8b992efbae7f9070a96.tar.gz |
SERVER-8598 ConfigVersion is *not* the same as ChunkVersion, cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/ops/query.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/d_logic.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/d_logic.h | 19 | ||||
-rw-r--r-- | src/mongo/s/d_state.cpp | 30 |
4 files changed, 28 insertions, 27 deletions
diff --git a/src/mongo/db/ops/query.cpp b/src/mongo/db/ops/query.cpp index 5d41d07938c..3a0e8d70674 100644 --- a/src/mongo/db/ops/query.cpp +++ b/src/mongo/db/ops/query.cpp @@ -682,7 +682,7 @@ namespace mongo { const BSONObj &query, const BSONObj &order, const shared_ptr<ParsedQuery> &pq_shared, const BSONObj &oldPlan, - const ConfigVersion &shardingVersionAtStart, + const ChunkVersion &shardingVersionAtStart, scoped_ptr<PageFaultRetryableSection>& parentPageFaultSection, scoped_ptr<NoPageFaultsAllowed>& noPageFault, Message &result ) { @@ -1025,7 +1025,7 @@ namespace mongo { try { Client::ReadContext ctx( ns , dbpath ); // read locks - const ConfigVersion shardingVersionAtStart = shardingState.getVersion( ns ); + const ChunkVersion shardingVersionAtStart = shardingState.getVersion( ns ); replVerifyReadsOk(&pq); diff --git a/src/mongo/s/d_logic.cpp b/src/mongo/s/d_logic.cpp index e6a3b97b524..be03ddf02de 100644 --- a/src/mongo/s/d_logic.cpp +++ b/src/mongo/s/d_logic.cpp @@ -56,7 +56,7 @@ namespace mongo { const char *ns = d.getns(); string errmsg; // We don't care about the version here, since we're returning it later in the writeback - ConfigVersion received, wanted; + ChunkVersion received, wanted; if ( shardVersionOk( ns , errmsg, received, wanted ) ) { return false; } diff --git a/src/mongo/s/d_logic.h b/src/mongo/s/d_logic.h index 57e54e6025a..0c437c423f5 100644 --- a/src/mongo/s/d_logic.h +++ b/src/mongo/s/d_logic.h @@ -30,8 +30,6 @@ namespace mongo { class Database; class DiskLoc; - typedef ChunkVersion ConfigVersion; - // -------------- // --- global state --- // -------------- @@ -61,8 +59,8 @@ namespace mongo { // versioning support bool hasVersion( const string& ns ); - bool hasVersion( const string& ns , ConfigVersion& version ); - const ConfigVersion getVersion( const string& ns ) const; + bool hasVersion( const string& ns , ChunkVersion& version ); + const ChunkVersion getVersion( const string& ns ) const; /** * Uninstalls the manager for a given collection. This should be used when the collection is dropped. @@ -89,7 +87,7 @@ namespace mongo { * @param version (IN) the client believe this collection is on and (OUT) the version the manager is actually in * @return true if the access can be allowed at the provided version */ - bool trySetVersion( const string& ns , ConfigVersion& version ); + bool trySetVersion( const string& ns , ChunkVersion& version ); void appendInfo( BSONObjBuilder& b ); @@ -183,8 +181,8 @@ namespace mongo { bool hasID() const { return _id.isSet(); } void setID( const OID& id ); - const ConfigVersion getVersion( const string& ns ) const; - void setVersion( const string& ns , const ConfigVersion& version ); + const ChunkVersion getVersion( const string& ns ) const; + void setVersion( const string& ns , const ChunkVersion& version ); static ShardedConnectionInfo* get( bool create ); static void reset(); @@ -202,7 +200,7 @@ namespace mongo { OID _id; bool _forceVersionOk; // if this is true, then chunk version #s aren't check, and all ops are allowed - typedef map<string,ConfigVersion> NSVersionMap; + typedef map<string,ChunkVersion> NSVersionMap; NSVersionMap _versions; static boost::thread_specific_ptr<ShardedConnectionInfo> _tl; @@ -238,7 +236,10 @@ namespace mongo { * @return true if the current threads shard version is ok, or not in sharded version * Also returns an error message and the Config/ChunkVersions causing conflicts */ - bool shardVersionOk( const string& ns , string& errmsg, ConfigVersion& received, ConfigVersion& wanted ); + bool shardVersionOk( const string& ns, + string& errmsg, + ChunkVersion& received, + ChunkVersion& wanted ); /** * @return true if we took care of the message and nothing else should be done diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp index 28398be504c..4a671f14372 100644 --- a/src/mongo/s/d_state.cpp +++ b/src/mongo/s/d_state.cpp @@ -130,7 +130,7 @@ namespace mongo { return it != _chunks.end(); } - bool ShardingState::hasVersion( const string& ns , ConfigVersion& version ) { + bool ShardingState::hasVersion( const string& ns , ChunkVersion& version ) { scoped_lock lk(_mutex); ChunkManagersMap::const_iterator it = _chunks.find(ns); @@ -142,7 +142,7 @@ namespace mongo { return true; } - const ConfigVersion ShardingState::getVersion( const string& ns ) const { + const ChunkVersion ShardingState::getVersion( const string& ns ) const { scoped_lock lk(_mutex); ChunkManagersMap::const_iterator it = _chunks.find( ns ); @@ -151,7 +151,7 @@ namespace mongo { return p->getVersion(); } else { - return ConfigVersion( 0, OID() ); + return ChunkVersion( 0, OID() ); } } @@ -197,7 +197,7 @@ namespace mongo { _chunks.erase( ns ); } - bool ShardingState::trySetVersion( const string& ns , ConfigVersion& version /* IN-OUT */ ) { + bool ShardingState::trySetVersion( const string& ns , ChunkVersion& version /* IN-OUT */ ) { // Currently this function is called after a getVersion(), which is the first "check", and the assumption here // is that we don't do anything nearly as long as a remote query in a thread between then and now. @@ -223,7 +223,7 @@ namespace mongo { // + two clients reloaded // one triggered the 'slow path' (below) // when the second's request gets here, the version is already current - ConfigVersion storedVersion; + ChunkVersion storedVersion; ShardChunkManagerPtr currManager; { scoped_lock lk( _mutex ); @@ -270,7 +270,7 @@ namespace mongo { // Handle the case where the collection isn't sharded more gracefully if( p->getKeyPattern().isEmpty() ){ - version = ConfigVersion( 0, OID() ); + version = ChunkVersion( 0, OID() ); // There was an error getting any data for this collection, return false return false; } @@ -367,17 +367,17 @@ namespace mongo { _tl.reset(); } - const ConfigVersion ShardedConnectionInfo::getVersion( const string& ns ) const { + const ChunkVersion ShardedConnectionInfo::getVersion( const string& ns ) const { NSVersionMap::const_iterator it = _versions.find( ns ); if ( it != _versions.end() ) { return it->second; } else { - return ConfigVersion( 0, OID() ); + return ChunkVersion( 0, OID() ); } } - void ShardedConnectionInfo::setVersion( const string& ns , const ConfigVersion& version ) { + void ShardedConnectionInfo::setVersion( const string& ns , const ChunkVersion& version ) { _versions[ns] = version; } @@ -578,17 +578,17 @@ namespace mongo { return false; } - if( ! ConfigVersion::canParseBSON( cmdObj, "version" ) ){ + if( ! ChunkVersion::canParseBSON( cmdObj, "version" ) ){ errmsg = "need to specify version"; return false; } - const ConfigVersion version = ConfigVersion::fromBSON( cmdObj, "version" ); + const ChunkVersion version = ChunkVersion::fromBSON( cmdObj, "version" ); // step 3 - const ConfigVersion oldVersion = info->getVersion(ns); - const ConfigVersion globalVersion = shardingState.getVersion(ns); + const ChunkVersion oldVersion = info->getVersion(ns); + const ChunkVersion globalVersion = shardingState.getVersion(ns); oldVersion.addToBSON( result, "oldVersion" ); @@ -706,7 +706,7 @@ namespace mongo { // If this was a reset of a collection, inform mongos to do a full reload if( ! currVersion.isSet() ){ - ConfigVersion( 0, OID() ).addToBSON( result, "version" ); + ChunkVersion( 0, OID() ).addToBSON( result, "version" ); result.appendBool( "reloadConfig", true ); } else{ @@ -793,7 +793,7 @@ namespace mongo { * @ return true if not in sharded mode or if version for this client is ok */ - bool shardVersionOk( const string& ns , string& errmsg, ConfigVersion& received, ConfigVersion& wanted ) { + bool shardVersionOk( const string& ns , string& errmsg, ChunkVersion& received, ChunkVersion& wanted ) { if ( ! shardingState.enabled() ) return true; |