diff options
author | Randolph Tan <randolph@10gen.com> | 2014-06-02 17:59:40 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-06-06 10:31:49 -0400 |
commit | 7915e212dc903f8d65b5c67d3c1bc501e0d3e610 (patch) | |
tree | f2c52ab9345f6622d5c351478b74c26f9d6cd646 /src/mongo | |
parent | 0d5acb0e3a6b0f1cdf7f252aa9a13afb1e884848 (diff) | |
download | mongo-7915e212dc903f8d65b5c67d3c1bc501e0d3e610.tar.gz |
SERVER-11256 improve handling of empty vs nonexistent CollectionMetadata
Remove long constructor for ChunkVersion
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/client/parallel.cpp | 15 | ||||
-rw-r--r-- | src/mongo/s/chunk.cpp | 12 | ||||
-rw-r--r-- | src/mongo/s/chunk.h | 2 | ||||
-rw-r--r-- | src/mongo/s/chunk_diff-inl.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/chunk_version.h | 18 | ||||
-rw-r--r-- | src/mongo/s/chunk_version_test.cpp | 1 | ||||
-rw-r--r-- | src/mongo/s/d_state.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/strategy.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/version_manager.cpp | 5 |
9 files changed, 39 insertions, 27 deletions
diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index 9645f4dc830..20b3dc2b53d 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -1266,7 +1266,14 @@ namespace mongo { if ( conns[i]->setVersion() ) { conns[i]->done(); // Version is zero b/c this is deprecated codepath - staleConfigExs.push_back( (string)"stale config detected for " + RecvStaleConfigException( _ns , "ParallelCursor::_init" , ChunkVersion( 0, OID() ), ChunkVersion( 0, OID() ), true ).what() + errLoc ); + staleConfigExs.push_back( + str::stream() << "stale config detected for " + << RecvStaleConfigException( _ns, + "ParallelCursor::_init", + ChunkVersion( 0, 0, OID() ), + ChunkVersion( 0, 0, OID() ), + true ).what() + << errLoc ); break; } @@ -1420,7 +1427,11 @@ namespace mongo { if( throwException && staleConfigExs.size() > 0 ){ // Version is zero b/c this is deprecated codepath - throw RecvStaleConfigException( _ns , errMsg.str() , ChunkVersion( 0, OID() ), ChunkVersion( 0, OID() ), ! allConfigStale ); + throw RecvStaleConfigException( _ns, + errMsg.str(), + ChunkVersion( 0, 0, OID() ), + ChunkVersion( 0, 0, OID() ), + !allConfigStale ); } else if( throwException ) throw DBException( errMsg.str(), 14827 ); diff --git a/src/mongo/s/chunk.cpp b/src/mongo/s/chunk.cpp index cf89ddc1a9e..c41ac9f3846 100644 --- a/src/mongo/s/chunk.cpp +++ b/src/mongo/s/chunk.cpp @@ -76,7 +76,7 @@ namespace mongo { bool Chunk::ShouldAutoSplit = true; Chunk::Chunk(const ChunkManager * manager, BSONObj from) - : _manager(manager), _lastmod(0, OID()), _dataWritten(mkDataWritten()) + : _manager(manager), _lastmod(0, 0, OID()), _dataWritten(mkDataWritten()) { string ns = from.getStringField(ChunkType::ns().c_str()); _shard.reset(from.getStringField(ChunkType::shard().c_str())); @@ -806,7 +806,7 @@ namespace mongo { { // Reset the max version, but not the epoch, when we aren't loading from the oldManager - _version = ChunkVersion( 0, _version.epoch() ); + _version = ChunkVersion( 0, 0, _version.epoch() ); set<ChunkVersion> minorVersions; // If we have a previous version of the ChunkManager to work from, use that info to reduce @@ -872,7 +872,7 @@ namespace mongo { // Set all our data to empty chunkMap.clear(); shardVersions.clear(); - _version = ChunkVersion( 0, OID() ); + _version = ChunkVersion( 0, 0, OID() ); return true; } @@ -896,7 +896,7 @@ namespace mongo { // Set all our data to empty to be extra safe chunkMap.clear(); shardVersions.clear(); - _version = ChunkVersion( 0, OID() ); + _version = ChunkVersion( 0, 0, OID() ); return allInconsistent; } @@ -1110,7 +1110,7 @@ namespace mongo { } } - _version = ChunkVersion( 0, version.epoch() ); + _version = ChunkVersion( 0, 0, version.epoch() ); } ChunkPtr ChunkManager::findIntersectingChunk( const BSONObj& point ) const { @@ -1437,7 +1437,7 @@ namespace mongo { if ( ! setShardVersion( conn.conn(), _ns, - ChunkVersion( 0, OID() ), + ChunkVersion( 0, 0, OID() ), ChunkManagerPtr(), true, res ) ) { diff --git a/src/mongo/s/chunk.h b/src/mongo/s/chunk.h index 96033689365..f8f18df1474 100644 --- a/src/mongo/s/chunk.h +++ b/src/mongo/s/chunk.h @@ -75,7 +75,7 @@ namespace mongo { // serialization support // - void serialize(BSONObjBuilder& to, ChunkVersion myLastMod=ChunkVersion(0,OID())); + void serialize(BSONObjBuilder& to, ChunkVersion myLastMod = ChunkVersion(0, 0, OID())); // // chunk boundary support diff --git a/src/mongo/s/chunk_diff-inl.cpp b/src/mongo/s/chunk_diff-inl.cpp index aa06349e8ec..daa38e08866 100644 --- a/src/mongo/s/chunk_diff-inl.cpp +++ b/src/mongo/s/chunk_diff-inl.cpp @@ -157,7 +157,9 @@ namespace mongo { warning() << "got invalid chunk version " << chunkVersion << " in document " << diffChunkDoc << " when trying to load differing chunks at version " - << ChunkVersion( _maxVersion->toLong(), currEpoch ) << endl; + << ChunkVersion( _maxVersion->majorVersion(), + _maxVersion->minorVersion(), + currEpoch ) << endl; // Don't keep loading, since we know we'll be broken here return -1; diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h index 6ed2613f225..c98e5f78971 100644 --- a/src/mongo/s/chunk_version.h +++ b/src/mongo/s/chunk_version.h @@ -68,10 +68,6 @@ namespace mongo { : _minor(minor),_major(major), _epoch(epoch) { } - ChunkVersion( unsigned long long ll, const OID& epoch ) - : _combined( ll ), _epoch(epoch) { - } - static ChunkVersion DROPPED() { return ChunkVersion( 0, 0, OID() ); // dropped OID is zero time, zero machineId/inc } @@ -87,6 +83,12 @@ namespace mongo { return version; } + static ChunkVersion fromDeprecatedLong(unsigned long long num, const OID& epoch) { + ChunkVersion version(0, 0, epoch); + version._combined = num; + return version; + } + static bool isDroppedVersion( const ChunkVersion& version ) { return version.majorVersion() == 0 && version.minorVersion() == 0 && version.epoch() == DROPPED().epoch(); @@ -262,17 +264,13 @@ namespace mongo { return ChunkVersion( 0, 0, el.OID() ); } - if( el.isNumber() ){ - return ChunkVersion( static_cast<unsigned long long>(el.numberLong()), OID() ); - } - if( type == Timestamp || type == Date ){ - return ChunkVersion( el._numberLong(), OID() ); + return fromDeprecatedLong( el._numberLong(), OID() ); } *canParse = false; - return ChunkVersion( 0, OID() ); + return ChunkVersion( 0, 0, OID() ); } // diff --git a/src/mongo/s/chunk_version_test.cpp b/src/mongo/s/chunk_version_test.cpp index 52183487e21..914e636c7f4 100644 --- a/src/mongo/s/chunk_version_test.cpp +++ b/src/mongo/s/chunk_version_test.cpp @@ -49,7 +49,6 @@ namespace { * <OID> is a value of type OID. * */ - TEST(Compatibility, LegacyFormatA) { BSONObjBuilder versionObjB; versionObjB.appendTimestamp( "testVersion", diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp index bddaf05be79..1fe950d3ee4 100644 --- a/src/mongo/s/d_state.cpp +++ b/src/mongo/s/d_state.cpp @@ -180,7 +180,7 @@ namespace mongo { return p->getShardVersion(); } else { - return ChunkVersion( 0, OID() ); + return ChunkVersion( 0, 0, OID() ); } } @@ -785,7 +785,7 @@ namespace mongo { return it->second; } else { - return ChunkVersion( 0, OID() ); + return ChunkVersion( 0, 0, OID() ); } } diff --git a/src/mongo/s/strategy.cpp b/src/mongo/s/strategy.cpp index fcca41f719d..5a74016dc80 100644 --- a/src/mongo/s/strategy.cpp +++ b/src/mongo/s/strategy.cpp @@ -106,7 +106,10 @@ namespace mongo { if ( qr->resultFlags() & ResultFlag_ShardConfigStale ) { dbcon.done(); // Version is zero b/c this is deprecated codepath - throw RecvStaleConfigException( r.getns() , "Strategy::doQuery", ChunkVersion( 0, OID() ), ChunkVersion( 0, OID() ) ); + throw RecvStaleConfigException( r.getns(), + "Strategy::doQuery", + ChunkVersion( 0, 0, OID() ), + ChunkVersion( 0, 0, OID() )); } } diff --git a/src/mongo/s/version_manager.cpp b/src/mongo/s/version_manager.cpp index 02e9ff58b25..f966be02983 100644 --- a/src/mongo/s/version_manager.cpp +++ b/src/mongo/s/version_manager.cpp @@ -242,7 +242,7 @@ namespace mongo { << conn_in->getServerAddress() << ")" ); throw SendStaleConfigException( ns, msg, - refManager->getVersion( shard ), ChunkVersion( 0, OID() )); + refManager->getVersion( shard ), ChunkVersion( 0, 0, OID() )); } // has the ChunkManager been reloaded since the last time we updated the connection-level version? @@ -252,8 +252,7 @@ namespace mongo { return false; } - - ChunkVersion version = ChunkVersion( 0, OID() ); + ChunkVersion version = ChunkVersion( 0, 0, OID() ); if ( isSharded && manager ) { version = manager->getVersion( Shard::make( conn->getServerAddress() ) ); } |