diff options
author | Ben Caimano <ben.caimano@10gen.com> | 2020-10-08 02:02:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-15 17:21:11 +0000 |
commit | 5a9d2dd204f41b4a02fe83d710f3f38c6092b322 (patch) | |
tree | a45a543241ad8b4159e3356ce4d4db151dd5af07 /src/mongo/s/commands/cluster_is_master_cmd.cpp | |
parent | dba33bef953f8d1740523c159c66f0fb3b9b53d4 (diff) | |
download | mongo-5a9d2dd204f41b4a02fe83d710f3f38c6092b322.tar.gz |
SERVER-49336 Set ClientMetadata before CommandInvocations are run
This patch does the following:
- Always parses ClientMetadata before command implementations are run.
- Marks general ClientMetadata as final in the first hello.
- Removes client_metadata_ismaster.* (SERVER-50517)
- Switches references to "isMaster" to "hello" (SERVER-50517)
- Binds "$client" metadata as a decoration (SERVER-50804)
Diffstat (limited to 'src/mongo/s/commands/cluster_is_master_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_is_master_cmd.cpp | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index 532f29c7e04..1ae4b497576 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -42,7 +42,6 @@ #include "mongo/db/wire_version.h" #include "mongo/logv2/log.h" #include "mongo/rpc/metadata/client_metadata.h" -#include "mongo/rpc/metadata/client_metadata_ismaster.h" #include "mongo/rpc/topology_version_gen.h" #include "mongo/s/mongos_topology_coordinator.h" #include "mongo/transport/message_compressor_manager.h" @@ -99,34 +98,8 @@ public: waitInHello.pauseWhileSet(opCtx); - auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient()); - bool seenIsMaster = clientMetadataIsMasterState.hasSeenIsMaster(); - if (!seenIsMaster) { - clientMetadataIsMasterState.setSeenIsMaster(); - } - - BSONElement element = cmdObj[kMetadataDocumentName]; - if (!element.eoo()) { - if (seenIsMaster) { - uasserted(ErrorCodes::ClientMetadataCannotBeMutated, - "The client metadata document may only be sent in the first isMaster"); - } - - auto swParseClientMetadata = ClientMetadata::parse(element); - uassertStatusOK(swParseClientMetadata.getStatus()); - - invariant(swParseClientMetadata.getValue()); - - swParseClientMetadata.getValue().get().logClientMetadata(opCtx->getClient()); - - swParseClientMetadata.getValue().get().setMongoSMetadata( - getHostNameCachedAndPort(), - opCtx->getClient()->clientAddress(true), - VersionInfoInterface::instance().version()); - - clientMetadataIsMasterState.setClientMetadata( - opCtx->getClient(), std::move(swParseClientMetadata.getValue())); - } + auto client = opCtx->getClient(); + ClientMetadata::tryFinalize(client); // If a client is following the awaitable isMaster protocol, maxAwaitTimeMS should be // present if and only if topologyVersion is present in the request. |