summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Gonzalez <adriangonzalezmontemayor@gmail.com>2023-03-21 15:30:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-21 16:45:23 +0000
commit164fa714a90ea9077fdb7c67b870ca36f32eda06 (patch)
tree6bf92f52ec797aabea19da8efba7fec3536dbc68
parent2c0275949e7e189654ec2259df7bb3389ced780a (diff)
downloadmongo-164fa714a90ea9077fdb7c67b870ca36f32eda06.tar.gz
SERVER-74460 Omit information for QE collections
-rw-r--r--etc/backports_required_for_multiversion_tests.yml4
-rw-r--r--src/mongo/db/commands/count_cmd.cpp1
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp8
-rw-r--r--src/mongo/db/commands/find_cmd.cpp1
-rw-r--r--src/mongo/db/commands/fle2_compact_cmd.cpp1
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp1
-rw-r--r--src/mongo/db/commands/write_commands.cpp28
-rw-r--r--src/mongo/db/curop.h3
-rw-r--r--src/mongo/db/fle_crud.cpp8
-rw-r--r--src/mongo/db/stats/SConscript1
-rw-r--r--src/mongo/db/stats/top.cpp33
-rw-r--r--src/mongo/db/stats/top.h2
12 files changed, 64 insertions, 27 deletions
diff --git a/etc/backports_required_for_multiversion_tests.yml b/etc/backports_required_for_multiversion_tests.yml
index 53f6dc7bd0b..9e6b3be3d7b 100644
--- a/etc/backports_required_for_multiversion_tests.yml
+++ b/etc/backports_required_for_multiversion_tests.yml
@@ -342,6 +342,8 @@ last-continuous:
ticket: SERVER-73601
- test_file: src/mongo/db/modules/enterprise/jstests/fle2/collection_coll_stats.js
ticket: SERVER-74461
+ - test_file: src/mongo/db/modules/enterprise/jstests/fle2/top_command.js
+ ticket: SERVER-74460
suites: null
last-lts:
all:
@@ -753,4 +755,6 @@ last-lts:
ticket: SERVER-73601
- test_file: src/mongo/db/modules/enterprise/jstests/fle2/collection_coll_stats.js
ticket: SERVER-74461
+ - test_file: src/mongo/db/modules/enterprise/jstests/fle2/top_command.js
+ ticket: SERVER-74460
suites: null
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 53f473a3137..b564094df93 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -248,6 +248,7 @@ public:
curOp->beginQueryPlanningTimer();
if (shouldDoFLERewrite(request)) {
processFLECountD(opCtx, nss, &request);
+ curOp->debug().shouldOmitDiagnosticInformation = true;
}
if (request.getMirrored().value_or(false)) {
const auto& invocation = CommandInvocation::get(opCtx);
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index e28d2e61b4d..9e2c811d5f8 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -505,9 +505,11 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::typedRun(
validate(req);
- if (req.getEncryptionInformation().has_value() &&
- !req.getEncryptionInformation()->getCrudProcessed().get_value_or(false)) {
- return processFLEFindAndModify(opCtx, req);
+ if (req.getEncryptionInformation().has_value()) {
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
+ if (!req.getEncryptionInformation()->getCrudProcessed().get_value_or(false)) {
+ return processFLEFindAndModify(opCtx, req);
+ }
}
const NamespaceString& nsString = req.getNamespace();
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index c4b488da553..55be84ff88e 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -792,6 +792,7 @@ public:
// Set the telemetryStoreKey to none so telemetry isn't collected when we've done a
// FLE rewrite.
CurOp::get(opCtx)->debug().telemetryStoreKey = boost::none;
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
}
if (findCommand->getMirrored().value_or(false)) {
diff --git a/src/mongo/db/commands/fle2_compact_cmd.cpp b/src/mongo/db/commands/fle2_compact_cmd.cpp
index 0fcc330e2c9..a58c0f6eef1 100644
--- a/src/mongo/db/commands/fle2_compact_cmd.cpp
+++ b/src/mongo/db/commands/fle2_compact_cmd.cpp
@@ -90,6 +90,7 @@ CompactStats compactEncryptedCompactionCollection(OperationContext* opCtx,
}
validateCompactRequest(request, *edc);
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
auto namespaces =
uassertStatusOK(EncryptedStateCollectionsNamespaces::createFromDataCollection(*edc));
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index 8130d473d00..db2f4e692d5 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -1010,6 +1010,7 @@ Status runAggregate(OperationContext* opCtx,
// If the aggregate command supports encrypted collections, do rewrites of the pipeline to
// support querying against encrypted fields.
if (shouldDoFLERewrite(request)) {
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
// After this rewriting, the encryption info does not need to be kept around.
pipeline = processFLEPipelineD(
opCtx, nss, request.getEncryptionInformation().value(), std::move(pipeline));
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp
index ee4deb5dd7c..62ce1650472 100644
--- a/src/mongo/db/commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands.cpp
@@ -283,13 +283,15 @@ public:
write_ops::InsertCommandReply typedRun(OperationContext* opCtx) final try {
doTransactionValidationForWrites(opCtx, ns());
-
- if (request().getEncryptionInformation().has_value() &&
- !request().getEncryptionInformation()->getCrudProcessed()) {
- write_ops::InsertCommandReply insertReply;
- auto batch = processFLEInsert(opCtx, request(), &insertReply);
- if (batch == FLEBatchResult::kProcessed) {
- return insertReply;
+ if (request().getEncryptionInformation().has_value()) {
+ // Flag set here and in fle_crud.cpp since this only executes on a mongod.
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
+ if (!request().getEncryptionInformation()->getCrudProcessed()) {
+ write_ops::InsertCommandReply insertReply;
+ auto batch = processFLEInsert(opCtx, request(), &insertReply);
+ if (batch == FLEBatchResult::kProcessed) {
+ return insertReply;
+ }
}
}
@@ -447,10 +449,12 @@ public:
doTransactionValidationForWrites(opCtx, ns());
write_ops::UpdateCommandReply updateReply;
OperationSource source = OperationSource::kStandard;
-
- if (request().getEncryptionInformation().has_value() &&
- !request().getEncryptionInformation().value().getCrudProcessed()) {
- return processFLEUpdate(opCtx, request());
+ if (request().getEncryptionInformation().has_value()) {
+ // Flag set here and in fle_crud.cpp since this only executes on a mongod.
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
+ if (!request().getEncryptionInformation().value().getCrudProcessed()) {
+ return processFLEUpdate(opCtx, request());
+ }
}
if (isTimeseries(opCtx, request())) {
@@ -654,6 +658,8 @@ public:
OperationSource source = OperationSource::kStandard;
if (request().getEncryptionInformation().has_value()) {
+ // Flag set here and in fle_crud.cpp since this only executes on a mongod.
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
return processFLEDelete(opCtx, request());
}
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 178e389982a..6cc8bea1b8c 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -363,6 +363,9 @@ public:
// resolved views per query, a hash map would unlikely provide any benefits.
std::map<NamespaceString, std::pair<std::vector<NamespaceString>, std::vector<BSONObj>>>
resolvedViews;
+
+ // Flag to decide if diagnostic information should be omitted.
+ bool shouldOmitDiagnosticInformation{false};
};
/**
diff --git a/src/mongo/db/fle_crud.cpp b/src/mongo/db/fle_crud.cpp
index c44c8b801c4..fe5146d0330 100644
--- a/src/mongo/db/fle_crud.cpp
+++ b/src/mongo/db/fle_crud.cpp
@@ -360,6 +360,7 @@ std::pair<FLEBatchResult, write_ops::InsertCommandReply> processInsert(
const write_ops::InsertCommandRequest& insertRequest,
GetTxnCallback getTxns) {
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
auto documents = insertRequest.getDocuments();
std::vector<write_ops::WriteError> writeErrors;
@@ -439,6 +440,7 @@ write_ops::DeleteCommandReply processDelete(OperationContext* opCtx,
}
}
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
std::shared_ptr<txn_api::SyncTransactionWithRetries> trun = getTxns(opCtx);
auto reply = std::make_shared<write_ops::DeleteCommandReply>();
@@ -533,6 +535,7 @@ write_ops::UpdateCommandReply processUpdate(OperationContext* opCtx,
write_ops::UpdateModification::Type::kReplacement);
}
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
std::shared_ptr<txn_api::SyncTransactionWithRetries> trun = getTxns(opCtx);
// The function that handles the transaction may outlive this function so we need to use
@@ -1012,6 +1015,7 @@ StatusWith<std::pair<ReplyType, OpMsgRequest>> processFindAndModifyRequest(
GetTxnCallback getTxns,
ProcessFindAndModifyCallback<ReplyType> processCallback) {
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
validateFindAndModifyRequest(findAndModifyRequest);
std::shared_ptr<txn_api::SyncTransactionWithRetries> trun = getTxns(opCtx);
@@ -1362,6 +1366,7 @@ FLEBatchResult processFLEBatch(OperationContext* opCtx,
BatchedCommandResponse* response,
boost::optional<OID> targetEpoch) {
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
if (request.getWriteCommandRequestBase().getEncryptionInformation()->getCrudProcessed()) {
return FLEBatchResult::kNotProcessed;
}
@@ -1431,6 +1436,8 @@ std::unique_ptr<BatchedCommandRequest> processFLEBatchExplain(
return expCtx;
};
+ CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation = true;
+
if (request.getBatchType() == BatchedCommandRequest::BatchType_Delete) {
auto deleteRequest = request.getDeleteRequest();
auto newDeleteOp = deleteRequest.getDeletes()[0];
@@ -1471,6 +1478,7 @@ write_ops::FindAndModifyCommandReply processFindAndModify(
FLEQueryInterface* queryImpl,
const write_ops::FindAndModifyCommandRequest& findAndModifyRequest) {
+ CurOp::get(expCtx->opCtx)->debug().shouldOmitDiagnosticInformation = true;
auto edcNss = findAndModifyRequest.getNamespace();
auto ei = findAndModifyRequest.getEncryptionInformation().value();
diff --git a/src/mongo/db/stats/SConscript b/src/mongo/db/stats/SConscript
index 4046c1ca2a9..b0a2a98198b 100644
--- a/src/mongo/db/stats/SConscript
+++ b/src/mongo/db/stats/SConscript
@@ -21,6 +21,7 @@ env.Library(
'operation_latency_histogram.cpp',
],
LIBDEPS=[
+ '$BUILD_DIR/mongo/db/query/op_metrics',
'$BUILD_DIR/mongo/db/server_base',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/namespace_string_database_name_util',
diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp
index 92b7276966f..5dbf6c1bbca 100644
--- a/src/mongo/db/stats/top.cpp
+++ b/src/mongo/db/stats/top.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/stats/top.h"
+#include "mongo/db/curop.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/service_context.h"
#include "mongo/util/namespace_string_util.h"
@@ -109,6 +110,9 @@ void Top::_record(OperationContext* opCtx,
LockType lockType,
long long micros,
Command::ReadWriteType readWriteType) {
+ if (c.isStatsRecordingAllowed) {
+ c.isStatsRecordingAllowed = !CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation;
+ }
_incrementHistogram(opCtx, micros, &c.opLatencyHistogram, readWriteType);
@@ -177,19 +181,22 @@ void Top::_appendToUsageMap(BSONObjBuilder& b, const UsageMap& map) const {
BSONObjBuilder bb(b.subobjStart(names[i]));
const CollectionData& coll = map.find(names[i])->second;
-
- _appendStatsEntry(b, "total", coll.total);
-
- _appendStatsEntry(b, "readLock", coll.readLock);
- _appendStatsEntry(b, "writeLock", coll.writeLock);
-
- _appendStatsEntry(b, "queries", coll.queries);
- _appendStatsEntry(b, "getmore", coll.getmore);
- _appendStatsEntry(b, "insert", coll.insert);
- _appendStatsEntry(b, "update", coll.update);
- _appendStatsEntry(b, "remove", coll.remove);
- _appendStatsEntry(b, "commands", coll.commands);
-
+ auto pos = names[i].find('.');
+ auto nss = NamespaceString(names[i].substr(0, pos), names[i].substr(pos + 1));
+
+ if (coll.isStatsRecordingAllowed && !nss.isFLE2StateCollection()) {
+ _appendStatsEntry(b, "total", coll.total);
+
+ _appendStatsEntry(b, "readLock", coll.readLock);
+ _appendStatsEntry(b, "writeLock", coll.writeLock);
+
+ _appendStatsEntry(b, "queries", coll.queries);
+ _appendStatsEntry(b, "getmore", coll.getmore);
+ _appendStatsEntry(b, "insert", coll.insert);
+ _appendStatsEntry(b, "update", coll.update);
+ _appendStatsEntry(b, "remove", coll.remove);
+ _appendStatsEntry(b, "commands", coll.commands);
+ }
bb.done();
}
}
diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h
index 358dc5d7164..ae4ac5a65dd 100644
--- a/src/mongo/db/stats/top.h
+++ b/src/mongo/db/stats/top.h
@@ -85,6 +85,8 @@ public:
UsageData remove;
UsageData commands;
OperationLatencyHistogram opLatencyHistogram;
+
+ bool isStatsRecordingAllowed{true};
};
enum class LockType {