diff options
Diffstat (limited to 'src/mongo/db/service_entry_point_common.cpp')
| -rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 976e37cabac..b83fe5656aa 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -84,7 +84,6 @@ #include "mongo/db/session_catalog_mongod.h" #include "mongo/db/stats/api_version_metrics.h" #include "mongo/db/stats/counters.h" -#include "mongo/db/stats/read_preference_metrics.h" #include "mongo/db/stats/resource_consumption_metrics.h" #include "mongo/db/stats/server_read_concern_metrics.h" #include "mongo/db/stats/top.h" @@ -502,8 +501,8 @@ void appendErrorLabelsAndTopologyVersion(OperationContext* opCtx, const auto replCoord = repl::ReplicationCoordinator::get(opCtx); // NotPrimary errors always include a topologyVersion, since we increment topologyVersion on // stepdown. ShutdownErrors only include a topologyVersion if the server is in quiesce mode, - // since we only increment the topologyVersion at shutdown and alert waiting isMaster/hello - // commands if the server enters quiesce mode. + // since we only increment the topologyVersion at shutdown and alert waiting isMaster commands + // if the server enters quiesce mode. const auto shouldAppendTopologyVersion = (replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet && isNotPrimaryError) || @@ -981,7 +980,7 @@ void CheckoutSessionAndInvokeCommand::_checkOutSession() { auto command = invocation->definition(); // Record readConcern usages for commands run inside transactions after unstashing the // transaction resources. - if (command->shouldAffectReadOptionCounters() && opCtx->inMultiDocumentTransaction()) { + if (command->shouldAffectReadConcernCounter() && opCtx->inMultiDocumentTransaction()) { ServerReadConcernMetrics::get(opCtx)->recordReadConcern(readConcernArgs, true /* isTransaction */); } @@ -1085,27 +1084,11 @@ void RunCommandImpl::_prologue() { // Record readConcern usages for commands run outside of transactions, excluding DBDirectClient. // For commands inside a transaction, they inherit the readConcern from the transaction. So we // will record their readConcern usages after we have unstashed the transaction resources. - if (!opCtx->getClient()->isInDirectClient() && command->shouldAffectReadOptionCounters() && + if (!opCtx->getClient()->isInDirectClient() && command->shouldAffectReadConcernCounter() && !opCtx->inMultiDocumentTransaction()) { ServerReadConcernMetrics::get(opCtx)->recordReadConcern(repl::ReadConcernArgs::get(opCtx), false /* isTransaction */); } - - auto const replCoord = repl::ReplicationCoordinator::get(opCtx); - // If the state is not primary or secondary, we skip collecting metrics. We also use the UNSAFE - // method in the replication coordinator, as collecting metrics around read preference usage is - // best-effort and should not contend for the replication coordinator mutex. - if (replCoord->getSettings().usingReplSets() && - replCoord->isInPrimaryOrSecondaryState_UNSAFE()) { - auto isPrimary = - replCoord->canAcceptWritesForDatabase_UNSAFE(opCtx, NamespaceString::kAdminDb); - // Skip incrementing metrics when the command is not a read operation, as we expect to all - // commands sent via the driver to inherit the read preference, even if we don't use it. - if (command->shouldAffectReadOptionCounters()) { - ReadPreferenceMetrics::get(opCtx)->recordReadPreference( - ReadPreferenceSetting::get(opCtx), _isInternalClient(), isPrimary); - } - } } void RunCommandImpl::_epilogue() { @@ -2018,20 +2001,7 @@ DbResponse makeCommandResponse(std::shared_ptr<HandleRequest::ExecutionContext> } } - try { - dbResponse.response = replyBuilder->done(); - } catch (const ExceptionFor<ErrorCodes::BSONObjectTooLarge>& ex) { - // Create a new reply builder as subsequently calling any methods on a builder after - // 'done()' results in undefined behavior. - auto errorReplyBuilder = execContext->getReplyBuilder(); - BSONObjBuilder metadataBob; - BSONObjBuilder extraFieldsBuilder; - appendClusterAndOperationTime( - opCtx, &extraFieldsBuilder, &metadataBob, LogicalTime::kUninitialized); - generateErrorResponse( - opCtx, errorReplyBuilder, ex.toStatus(), metadataBob.obj(), extraFieldsBuilder.obj()); - dbResponse.response = errorReplyBuilder->done(); - } + dbResponse.response = replyBuilder->done(); CurOp::get(opCtx)->debug().responseLength = dbResponse.response.header().dataLen(); return dbResponse; |
