diff options
author | Kruti Shah <kruti139@gmail.com> | 2023-04-20 15:32:53 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-20 16:57:13 +0000 |
commit | 39326a291fa35d95f1532cc009cf131837979e26 (patch) | |
tree | 423e733945375a3bb172a533122a8846f737802d /src/mongo/s/commands/cluster_find_and_modify_cmd.cpp | |
parent | 124eb7f41bfe3082cbe8067503eb02679ab20c6b (diff) | |
download | mongo-39326a291fa35d95f1532cc009cf131837979e26.tar.gz |
SERVER-69810 Add targeted and non-targeted serverStatus metrics for updateOne/deleteOne/findandmodify
Diffstat (limited to 'src/mongo/s/commands/cluster_find_and_modify_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_find_and_modify_cmd.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp index f994cbd0306..a1200ff9657 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -42,6 +42,7 @@ #include "mongo/db/internal_transactions_feature_flag_gen.h" #include "mongo/db/ops/write_ops_gen.h" #include "mongo/db/query/collation/collator_factory_interface.h" +#include "mongo/db/stats/counters.h" #include "mongo/db/storage/duplicate_key_error_info.h" #include "mongo/db/transaction/transaction_api.h" #include "mongo/executor/task_executor_pool.h" @@ -522,6 +523,7 @@ bool FindAndModifyCmd::run(OperationContext* opCtx, const BSONObj collation = getCollation(cmdObjForShard); if (write_without_shard_key::useTwoPhaseProtocol( opCtx, nss, false /* isUpdateOrDelete */, isUpsert, query, collation)) { + findAndModifyNonTargetedShardedCount.increment(1); auto allowShardKeyUpdatesWithoutFullShardKeyInQuery = opCtx->isRetryableWrite() || opCtx->inMultiDocumentTransaction(); @@ -551,6 +553,7 @@ bool FindAndModifyCmd::run(OperationContext* opCtx, &result); } } else { + findAndModifyTargetedShardedCount.increment(1); const auto let = getLet(cmdObjForShard); const auto rc = getLegacyRuntimeConstants(cmdObjForShard); const BSONObj shardKey = @@ -560,6 +563,7 @@ bool FindAndModifyCmd::run(OperationContext* opCtx, // key. This means that we always assume that a findAndModify request using _id is // targetable to a single shard. auto chunk = cm.findIntersectingChunk(shardKey, collation, true); + _runCommand(opCtx, chunk.getShardId(), cri.getShardVersion(chunk.getShardId()), @@ -571,6 +575,7 @@ bool FindAndModifyCmd::run(OperationContext* opCtx, &result); } } else { + findAndModifyUnshardedCount.increment(1); _runCommand(opCtx, cm.dbPrimary(), boost::make_optional(!cm.dbVersion().isFixed(), ShardVersion::UNSHARDED()), @@ -788,6 +793,7 @@ void FindAndModifyCmd::_handleWouldChangeOwningShardErrorRetryableWriteLegacy( cmdObj.getBoolField("upsert"), cmdObj.getObjectField("query"), getCollation(cmdObj))) { + findAndModifyNonTargetedShardedCount.increment(1); _runCommandWithoutShardKey(opCtx, nss, stripWriteConcern(cmdObj), @@ -796,6 +802,7 @@ void FindAndModifyCmd::_handleWouldChangeOwningShardErrorRetryableWriteLegacy( result); } else { + findAndModifyTargetedShardedCount.increment(1); _runCommand(opCtx, shardId, shardVersion, |