summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/find_cmd.cpp6
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp4
-rw-r--r--src/mongo/db/commands/mr.cpp4
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp15
-rw-r--r--src/mongo/db/dbcommands.cpp18
-rw-r--r--src/mongo/db/range_deleter_db_env.cpp4
-rw-r--r--src/mongo/db/s/SConscript3
-rw-r--r--src/mongo/db/s/collection_sharding_state.cpp1
-rw-r--r--src/mongo/db/s/migration_impl.cpp4
-rw-r--r--src/mongo/db/s/operation_sharding_state.cpp (renamed from src/mongo/db/s/operation_shard_version.cpp)44
-rw-r--r--src/mongo/db/s/operation_sharding_state.h (renamed from src/mongo/db/s/operation_shard_version.h)21
-rw-r--r--src/mongo/db/s/sharding_state.cpp4
-rw-r--r--src/mongo/s/chunk_version.cpp7
-rw-r--r--src/mongo/s/chunk_version.h6
-rw-r--r--src/mongo/s/d_split.cpp4
-rw-r--r--src/mongo/s/d_state.cpp8
16 files changed, 79 insertions, 74 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index cda3656ec90..62e0a08807f 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -49,7 +49,7 @@
#include "mongo/db/query/find.h"
#include "mongo/db/query/find_common.h"
#include "mongo/db/query/get_executor.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/stats/counters.h"
@@ -243,8 +243,8 @@ public:
ShardingState* const shardingState = ShardingState::get(txn);
- if (OperationShardVersion::get(txn).hasShardVersion() && shardingState->enabled()) {
- ChunkVersion receivedVersion = OperationShardVersion::get(txn).getShardVersion(nss);
+ if (OperationShardingState::get(txn).hasShardVersion() && shardingState->enabled()) {
+ ChunkVersion receivedVersion = OperationShardingState::get(txn).getShardVersion(nss);
ChunkVersion latestVersion;
// Wait for migration completion to get the correct chunk version.
const int maxTimeoutSec = 30;
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index e2b785b7f69..81b18386b8f 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -50,7 +50,7 @@
#include "mongo/db/query/getmore_request.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/oplog.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/stats/counters.h"
#include "mongo/s/chunk_version.h"
@@ -163,7 +163,7 @@ public:
CurOp::get(txn)->debug().cursorid = request.cursorid;
// Disable shard version checking - getmore commands are always unversioned
- OperationShardVersion::get(txn).setShardVersion(request.nss, ChunkVersion::IGNORED());
+ OperationShardingState::get(txn).setShardVersion(request.nss, ChunkVersion::IGNORED());
// Validate term before acquiring locks, if provided.
if (request.term) {
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 75fefbcb51f..593ae3dddd4 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -63,7 +63,7 @@
#include "mongo/db/range_preserver.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/catalog/catalog_cache.h"
@@ -584,7 +584,7 @@ unsigned long long _safeCount(OperationContext* txn,
int options = 0,
int limit = 0,
int skip = 0) {
- OperationShardVersion::IgnoreVersioningBlock ignoreVersion(txn, NamespaceString(ns));
+ OperationShardingState::IgnoreVersioningBlock ignoreVersion(txn, NamespaceString(ns));
return db.count(ns, query, options, limit, skip);
}
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 54ccaea09c3..d3fb03727e7 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -65,7 +65,7 @@
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/stats/counters.h"
@@ -197,11 +197,13 @@ bool checkShardVersion(OperationContext* txn,
const NamespaceString& nss = request.getTargetingNSS();
dassert(txn->lockState()->isCollectionLockedForMode(nss.ns(), MODE_IX));
- if (!OperationShardVersion::get(txn).hasShardVersion()) {
+ auto& oss = OperationShardingState::get(txn);
+
+ if (!oss.hasShardVersion()) {
return true;
}
- ChunkVersion operationShardVersion = OperationShardVersion::get(txn).getShardVersion(nss);
+ ChunkVersion operationShardVersion = oss.getShardVersion(nss);
if (ChunkVersion::isIgnoredVersion(operationShardVersion)) {
return true;
}
@@ -292,7 +294,6 @@ void WriteBatchExecutor::executeBatch(const BatchedCommandRequest& request,
OwnedPointerVector<BatchedUpsertDetail> upsertedOwned;
vector<BatchedUpsertDetail*>& upserted = upsertedOwned.mutableVector();
-
//
// Apply each batch item, possibly bulking some items together in the write lock.
// Stops on error if batch is ordered.
@@ -330,9 +331,9 @@ void WriteBatchExecutor::executeBatch(const BatchedCommandRequest& request,
if (staleBatch) {
ShardingState* shardingState = ShardingState::get(_txn);
- const OperationShardVersion& operationShardVersion = OperationShardVersion::get(_txn);
- const ChunkVersion& requestShardVersion =
- operationShardVersion.getShardVersion(request.getTargetingNSS());
+
+ auto& oss = OperationShardingState::get(_txn);
+ ChunkVersion requestShardVersion = oss.getShardVersion(request.getTargetingNSS());
//
// First, we refresh metadata if we need to based on the requested version.
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 79cdd098674..790c90b744a 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -86,7 +86,7 @@
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/write_concern.h"
@@ -97,6 +97,7 @@
#include "mongo/rpc/metadata/server_selection_metadata.h"
#include "mongo/rpc/metadata/sharding_metadata.h"
#include "mongo/rpc/protocol.h"
+#include "mongo/s/chunk_version.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/s/stale_exception.h" // for SendStaleConfigException
@@ -1206,14 +1207,14 @@ namespace {
// Symbolic names for indexes to make code more readable.
const std::size_t kCmdOptionMaxTimeMSField = 0;
const std::size_t kHelpField = 1;
-const std::size_t kShardVersionField = 2;
+const std::size_t kShardVersionFieldIdx = 2;
const std::size_t kQueryOptionMaxTimeMSField = 3;
// We make an array of the fields we need so we can call getFields once. This saves repeated
// scans over the command object.
const std::array<StringData, 4> neededFieldNames{LiteParsedQuery::cmdOptionMaxTimeMS,
Command::kHelpFieldName,
- OperationShardVersion::fieldName(),
+ ChunkVersion::kShardVersionField,
LiteParsedQuery::queryOptionMaxTimeMS};
} // namespace
@@ -1323,12 +1324,10 @@ void Command::execCommand(OperationContext* txn,
if (iAmPrimary && !txn->getClient()->isInDirectClient()) {
// Handle shard version and config optime information that may have been sent along with
// the command.
- auto& operationShardVersion = OperationShardVersion::get(txn);
- invariant(!operationShardVersion.hasShardVersion());
+ auto& oss = OperationShardingState::get(txn);
auto commandNS = NamespaceString(command->parseNs(dbname, request.getCommandArgs()));
- operationShardVersion.initializeFromCommand(commandNS,
- extractedFields[kShardVersionField]);
+ oss.initializeShardVersion(commandNS, extractedFields[kShardVersionFieldIdx]);
auto shardingState = ShardingState::get(txn);
if (shardingState->enabled()) {
@@ -1341,9 +1340,8 @@ void Command::execCommand(OperationContext* txn,
str::stream()
<< "Received a command with sharding chunk version information but this "
"node is not sharding aware: " << request.getCommandArgs().jsonString(),
- !operationShardVersion.hasShardVersion() ||
- ChunkVersion::isIgnoredVersion(
- operationShardVersion.getShardVersion(commandNS)));
+ !oss.hasShardVersion() ||
+ ChunkVersion::isIgnoredVersion(oss.getShardVersion(commandNS)));
}
}
diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp
index ab79c8311e7..0a4a6734913 100644
--- a/src/mongo/db/range_deleter_db_env.cpp
+++ b/src/mongo/db/range_deleter_db_env.cpp
@@ -40,7 +40,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/s/d_state.h"
#include "mongo/util/log.h"
@@ -74,7 +74,7 @@ bool RangeDeleterDBEnv::deleteRange(OperationContext* txn,
Client::initThreadIfNotAlready("RangeDeleter");
*deletedDocs = 0;
- OperationShardVersion::IgnoreVersioningBlock forceVersion(txn, NamespaceString(ns));
+ OperationShardingState::IgnoreVersioningBlock forceVersion(txn, NamespaceString(ns));
Helpers::RemoveSaver removeSaver("moveChunk", ns, taskDetails.options.removeSaverReason);
Helpers::RemoveSaver* removeSaverPtr = NULL;
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 665ff4ed032..18a6752a74d 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -5,7 +5,6 @@ Import("env")
env.Library(
target='metadata',
source=[
- 'operation_shard_version.cpp',
'collection_metadata.cpp',
'metadata_loader.cpp',
],
@@ -40,6 +39,7 @@ env.Library(
'migration_destination_manager.cpp',
'migration_impl.cpp',
'migration_source_manager.cpp',
+ 'operation_sharding_state.cpp',
'sharded_connection_info.cpp',
'sharding_state.cpp',
'sharding_state_recovery.cpp',
@@ -49,6 +49,7 @@ env.Library(
'$BUILD_DIR/mongo/bson/util/bson_extract',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/s/sharding_initialization',
+ 'metadata',
'migration_types',
],
LIBDEPS_TAGS=[
diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp
index e08c17ab4f4..9eec8de16e4 100644
--- a/src/mongo/db/s/collection_sharding_state.cpp
+++ b/src/mongo/db/s/collection_sharding_state.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/s/collection_metadata.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/chunk_version.h"
diff --git a/src/mongo/db/s/migration_impl.cpp b/src/mongo/db/s/migration_impl.cpp
index 248bad2d8e9..3a307e0c2be 100644
--- a/src/mongo/db/s/migration_impl.cpp
+++ b/src/mongo/db/s/migration_impl.cpp
@@ -37,7 +37,7 @@
#include "mongo/db/client.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/s/sharding_state_recovery.h"
#include "mongo/logger/ramlog.h"
@@ -134,7 +134,7 @@ Status ChunkMoveOperationState::initialize(const BSONObj& cmdObj) {
_toShardCS = toShard->getConnString();
}
- auto& operationVersion = OperationShardVersion::get(_txn);
+ auto& operationVersion = OperationShardingState::get(_txn);
if (!operationVersion.hasShardVersion()) {
return Status{ErrorCodes::InvalidOptions, "moveChunk command is missing shard version"};
}
diff --git a/src/mongo/db/s/operation_shard_version.cpp b/src/mongo/db/s/operation_sharding_state.cpp
index 5f47d80ef4f..906c491aac3 100644
--- a/src/mongo/db/s/operation_shard_version.cpp
+++ b/src/mongo/db/s/operation_sharding_state.cpp
@@ -28,38 +28,31 @@
#include "mongo/platform/basic.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
-#include "mongo/bson/util/bson_extract.h"
+#include "mongo/db/operation_context.h"
namespace mongo {
namespace {
-const OperationContext::Decoration<OperationShardVersion> shardingMetadataDecoration =
- OperationContext::declareDecoration<OperationShardVersion>();
+const OperationContext::Decoration<OperationShardingState> shardingMetadataDecoration =
+ OperationContext::declareDecoration<OperationShardingState>();
-const char kShardVersionField[] = "shardVersion";
const ChunkVersion kUnshardedVersion(ChunkVersion::UNSHARDED());
} // namespace mongo
-OperationShardVersion::OperationShardVersion() = default;
+OperationShardingState::OperationShardingState() = default;
-OperationShardVersion& OperationShardVersion::get(OperationContext* txn) {
+OperationShardingState& OperationShardingState::get(OperationContext* txn) {
return shardingMetadataDecoration(txn);
}
-StringData OperationShardVersion::fieldName() {
- return kShardVersionField;
-}
-
-void OperationShardVersion::initializeFromCommand(NamespaceString ns, const BSONObj& cmdObj) {
- initializeFromCommand(std::move(ns), cmdObj[fieldName()]);
-}
+void OperationShardingState::initializeShardVersion(NamespaceString ns,
+ const BSONElement& shardVersionElt) {
+ invariant(!hasShardVersion());
-void OperationShardVersion::initializeFromCommand(NamespaceString ns,
- const BSONElement& shardVersionElt) {
if (ns.isSystemDotIndexes()) {
setShardVersion(std::move(ns), ChunkVersion::IGNORED());
return;
@@ -76,14 +69,15 @@ void OperationShardVersion::initializeFromCommand(NamespaceString ns,
if (!hasVersion) {
return;
}
+
setShardVersion(std::move(ns), std::move(newVersion));
}
-bool OperationShardVersion::hasShardVersion() const {
+bool OperationShardingState::hasShardVersion() const {
return _hasVersion;
}
-const ChunkVersion& OperationShardVersion::getShardVersion(const NamespaceString& ns) const {
+const ChunkVersion& OperationShardingState::getShardVersion(const NamespaceString& ns) const {
if (_ns != ns) {
return kUnshardedVersion;
}
@@ -91,7 +85,7 @@ const ChunkVersion& OperationShardVersion::getShardVersion(const NamespaceString
return _shardVersion;
}
-void OperationShardVersion::setShardVersion(NamespaceString ns, ChunkVersion newVersion) {
+void OperationShardingState::setShardVersion(NamespaceString ns, ChunkVersion newVersion) {
// This currently supports only setting the shard version for one namespace.
invariant(!_hasVersion || _ns == ns);
invariant(!ns.isSystemDotIndexes() || ChunkVersion::isIgnoredVersion(newVersion));
@@ -101,16 +95,16 @@ void OperationShardVersion::setShardVersion(NamespaceString ns, ChunkVersion new
_hasVersion = true;
}
-void OperationShardVersion::_clear() {
+void OperationShardingState::_clear() {
_hasVersion = false;
_shardVersion = ChunkVersion();
_ns = NamespaceString();
}
-OperationShardVersion::IgnoreVersioningBlock::IgnoreVersioningBlock(OperationContext* txn,
- const NamespaceString& ns)
+OperationShardingState::IgnoreVersioningBlock::IgnoreVersioningBlock(OperationContext* txn,
+ const NamespaceString& ns)
: _txn(txn), _ns(ns) {
- auto& operationVersion = OperationShardVersion::get(txn);
+ auto& operationVersion = OperationShardingState::get(txn);
_hadOriginalVersion = operationVersion._hasVersion;
if (_hadOriginalVersion) {
_originalVersion = operationVersion.getShardVersion(ns);
@@ -118,8 +112,8 @@ OperationShardVersion::IgnoreVersioningBlock::IgnoreVersioningBlock(OperationCon
operationVersion.setShardVersion(ns, ChunkVersion::IGNORED());
}
-OperationShardVersion::IgnoreVersioningBlock::~IgnoreVersioningBlock() {
- auto& operationVersion = OperationShardVersion::get(_txn);
+OperationShardingState::IgnoreVersioningBlock::~IgnoreVersioningBlock() {
+ auto& operationVersion = OperationShardingState::get(_txn);
invariant(ChunkVersion::isIgnoredVersion(operationVersion.getShardVersion(_ns)));
if (_hadOriginalVersion) {
operationVersion.setShardVersion(_ns, _originalVersion);
diff --git a/src/mongo/db/s/operation_shard_version.h b/src/mongo/db/s/operation_sharding_state.h
index 1ec6e2bc1c1..7aa2fc919d3 100644
--- a/src/mongo/db/s/operation_shard_version.h
+++ b/src/mongo/db/s/operation_sharding_state.h
@@ -32,11 +32,12 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/operation_context.h"
#include "mongo/s/chunk_version.h"
namespace mongo {
+class OperationContext;
+
/**
* A decoration on OperationContext representing per-operation shard version metadata sent to mongod
* from mongos as a command parameter.
@@ -45,20 +46,18 @@ namespace mongo {
*
* Note: This only supports storing the version for a single namespace.
*/
-class OperationShardVersion {
- MONGO_DISALLOW_COPYING(OperationShardVersion);
+class OperationShardingState {
+ MONGO_DISALLOW_COPYING(OperationShardingState);
public:
class IgnoreVersioningBlock;
- OperationShardVersion();
-
- static StringData fieldName();
+ OperationShardingState();
/**
* Retrieves a reference to the shard version decorating the OperationContext, 'txn'.
*/
- static OperationShardVersion& get(OperationContext* txn);
+ static OperationShardingState& get(OperationContext* txn);
/**
* Parses shard version from the command parameters 'cmdObj' and stores the results in this
@@ -66,9 +65,11 @@ public:
* if no shard version is attached to the command.
*
* Expects the format { ..., shardVersion: [<version>, <epoch>] }.
+ *
+ * This initialization may only be performed once for the lifetime of the object, which
+ * coincides with the lifetime of the request.
*/
- void initializeFromCommand(NamespaceString ns, const BSONObj& cmdObj);
- void initializeFromCommand(NamespaceString ns, const BSONElement& shardVersionElement);
+ void initializeShardVersion(NamespaceString ns, const BSONElement& shardVersionElement);
/**
* Returns whether or not there is a shard version associated with this operation.
@@ -109,7 +110,7 @@ private:
* but may be part of a larger group of operations with a single OperationContext where the other
* sub-operations might still require versioning.
*/
-class OperationShardVersion::IgnoreVersioningBlock {
+class OperationShardingState::IgnoreVersioningBlock {
MONGO_DISALLOW_COPYING(IgnoreVersioningBlock);
public:
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index 501a40e0afb..a125a8b155d 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -43,7 +43,7 @@
#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/metadata_loader.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/rpc/metadata/config_server_metadata.h"
#include "mongo/s/catalog/catalog_manager.h"
@@ -923,7 +923,7 @@ bool ShardingState::needCollectionMetadata(OperationContext* txn, const string&
// Shard version information received from mongos may either by attached to the Client or
// directly to the OperationContext.
return ShardedConnectionInfo::get(client, false) ||
- OperationShardVersion::get(txn).hasShardVersion();
+ OperationShardingState::get(txn).hasShardVersion();
}
shared_ptr<CollectionMetadata> ShardingState::getCollectionMetadata(const string& ns) {
diff --git a/src/mongo/s/chunk_version.cpp b/src/mongo/s/chunk_version.cpp
index 4f0e067357b..467e2ff0043 100644
--- a/src/mongo/s/chunk_version.cpp
+++ b/src/mongo/s/chunk_version.cpp
@@ -40,13 +40,14 @@ namespace mongo {
namespace {
const char kVersion[] = "version";
-const char kShardVersion[] = "shardVersion";
} // namespace
+const char ChunkVersion::kShardVersionField[] = "shardVersion";
+
StatusWith<ChunkVersion> ChunkVersion::parseFromBSONForCommands(const BSONObj& obj) {
BSONElement versionElem;
- Status status = bsonExtractField(obj, kShardVersion, &versionElem);
+ Status status = bsonExtractField(obj, kShardVersionField, &versionElem);
if (!status.isOK())
return status;
@@ -101,7 +102,7 @@ void ChunkVersion::appendForSetShardVersion(BSONObjBuilder* builder) const {
}
void ChunkVersion::appendForCommands(BSONObjBuilder* builder) const {
- builder->appendArray(kShardVersion, toBSON());
+ builder->appendArray(kShardVersionField, toBSON());
}
BSONObj ChunkVersion::toBSON() const {
diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h
index cdc266fd613..669ee812c44 100644
--- a/src/mongo/s/chunk_version.h
+++ b/src/mongo/s/chunk_version.h
@@ -51,6 +51,12 @@ class StatusWith;
*/
struct ChunkVersion {
public:
+ /**
+ * The name for the shard version information field, which shard-aware commands should include
+ * if they want to convey shard version.
+ */
+ static const char kShardVersionField[];
+
ChunkVersion() : _combined(0), _epoch(OID()) {}
ChunkVersion(int major, int minor, const OID& epoch)
diff --git a/src/mongo/s/d_split.cpp b/src/mongo/s/d_split.cpp
index 5fd9af4ce63..7e36bbe3389 100644
--- a/src/mongo/s/d_split.cpp
+++ b/src/mongo/s/d_split.cpp
@@ -51,7 +51,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/catalog/type_chunk.h"
@@ -690,7 +690,7 @@ public:
// Mongos >= v3.2 sends the full version, v3.0 only sends the epoch.
// TODO(SERVER-20742): Stop parsing epoch separately after 3.2.
OID cmdEpoch;
- auto& operationVersion = OperationShardVersion::get(txn);
+ auto& operationVersion = OperationShardingState::get(txn);
if (operationVersion.hasShardVersion()) {
cmdVersion = operationVersion.getShardVersion(nss);
cmdEpoch = cmdVersion.epoch();
diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp
index 9206a6808b6..bf2e483b271 100644
--- a/src/mongo/s/d_state.cpp
+++ b/src/mongo/s/d_state.cpp
@@ -45,7 +45,7 @@
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
-#include "mongo/db/s/operation_shard_version.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/stale_exception.h"
@@ -250,10 +250,12 @@ bool shardVersionOk(OperationContext* txn,
return true;
}
+ auto& oss = OperationShardingState::get(txn);
+
// If there is a version attached to the OperationContext, use it as the received version.
// Otherwise, get the received version from the ShardedConnectionInfo.
- if (OperationShardVersion::get(txn).hasShardVersion()) {
- received = OperationShardVersion::get(txn).getShardVersion(NamespaceString(ns));
+ if (oss.hasShardVersion()) {
+ received = oss.getShardVersion(NamespaceString(ns));
} else {
ShardedConnectionInfo* info = ShardedConnectionInfo::get(client, false);
if (!info) {