diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-14 16:31:36 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-03-15 15:49:41 -0400 |
commit | 6210410de52b7695ffd2415ee2f1dea0374d24b2 (patch) | |
tree | a591bfc983193d50519f2e7bacffa2020d81bd02 | |
parent | b00065bafe48633f47a04f61c29abf71b1b4f075 (diff) | |
download | mongo-6210410de52b7695ffd2415ee2f1dea0374d24b2.tar.gz |
SERVER-23110 dbeval should not access collection sharding state
-rw-r--r-- | src/mongo/db/s/sharded_connection_info.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/s/sharded_connection_info.h | 13 | ||||
-rw-r--r-- | src/mongo/s/d_state.cpp | 13 |
3 files changed, 22 insertions, 8 deletions
diff --git a/src/mongo/db/s/sharded_connection_info.cpp b/src/mongo/db/s/sharded_connection_info.cpp index 13b60b08bae..24108490b01 100644 --- a/src/mongo/db/s/sharded_connection_info.cpp +++ b/src/mongo/db/s/sharded_connection_info.cpp @@ -73,12 +73,12 @@ void ShardedConnectionInfo::reset(Client* client) { clientSCI(client) = boost::none; } -const ChunkVersion ShardedConnectionInfo::getVersion(const std::string& ns) const { +ChunkVersion ShardedConnectionInfo::getVersion(const std::string& ns) const { NSVersionMap::const_iterator it = _versions.find(ns); if (it != _versions.end()) { return it->second; } else { - return ChunkVersion(0, 0, OID()); + return ChunkVersion::UNSHARDED(); } } diff --git a/src/mongo/db/s/sharded_connection_info.h b/src/mongo/db/s/sharded_connection_info.h index 4cc22fa3963..4cfae41c263 100644 --- a/src/mongo/db/s/sharded_connection_info.h +++ b/src/mongo/db/s/sharded_connection_info.h @@ -49,10 +49,19 @@ public: ShardedConnectionInfo(); ~ShardedConnectionInfo(); - const ChunkVersion getVersion(const std::string& ns) const; + static ShardedConnectionInfo* get(Client* client, bool create); + + /** + * Returns the shard version associated with the specified namespace on this connection. If no + * version is associated with the namespace returns ChunkVersion::UNSHARDED. + */ + ChunkVersion getVersion(const std::string& ns) const; + + /** + * Assigns a new version on the connection to the specified namespace. + */ void setVersion(const std::string& ns, const ChunkVersion& version); - static ShardedConnectionInfo* get(Client* client, bool create); static void reset(Client* client); static void addHook(); diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp index 9e1a413690a..5f9cfff51bf 100644 --- a/src/mongo/s/d_state.cpp +++ b/src/mongo/s/d_state.cpp @@ -218,12 +218,17 @@ bool haveLocalShardingInfo(OperationContext* txn, const string& ns) { return false; } - auto css = CollectionShardingState::get(txn, ns); - if (!css->getMetadata()) { - return false; + const auto& oss = OperationShardingState::get(txn); + if (oss.hasShardVersion()) { + return true; + } + + const auto& sci = ShardedConnectionInfo::get(txn->getClient(), false); + if (sci && !sci->getVersion(ns).isStrictlyEqualTo(ChunkVersion::UNSHARDED())) { + return true; } - return ShardedConnectionInfo::get(txn->getClient(), false) != nullptr; + return false; } void usingAShardConnection(const string& addr) {} |