summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshua <80741223+jlap199@users.noreply.github.com>2022-11-12 06:52:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-12 07:43:11 +0000
commit9298a0edec45d9e902cb0e9ef9875c3a06a76098 (patch)
treebcd83e9c7e3eee782bc36661d24d174e88701ef6
parent416feeeb85007bcd833eacab13f61500bae453da (diff)
downloadmongo-9298a0edec45d9e902cb0e9ef9875c3a06a76098.tar.gz
SERVER-71255 Remove clearEntries param from telemetry operator
-rw-r--r--src/mongo/db/pipeline/document_source_telemetry.cpp64
-rw-r--r--src/mongo/db/pipeline/document_source_telemetry.h14
-rw-r--r--src/mongo/db/pipeline/document_source_telemetry_test.cpp27
-rw-r--r--src/mongo/db/query/query_knobs.idl4
4 files changed, 21 insertions, 88 deletions
diff --git a/src/mongo/db/pipeline/document_source_telemetry.cpp b/src/mongo/db/pipeline/document_source_telemetry.cpp
index c03406fa097..36acd596241 100644
--- a/src/mongo/db/pipeline/document_source_telemetry.cpp
+++ b/src/mongo/db/pipeline/document_source_telemetry.cpp
@@ -33,9 +33,6 @@
#include "mongo/util/assert_util.h"
namespace mongo {
-namespace {
-const StringData kClearEntriesFieldName = "clearEntries"_sd;
-} // namespace
REGISTER_DOCUMENT_SOURCE(telemetry,
DocumentSourceTelemetry::LiteParsed::parse,
@@ -49,26 +46,12 @@ std::unique_ptr<DocumentSourceTelemetry::LiteParsed> DocumentSourceTelemetry::Li
<< " value must be an object. Found: " << typeName(spec.type()),
spec.type() == BSONType::Object);
- auto clearEntries = false;
-
- for (auto&& elem : spec.embeddedObject()) {
- const auto fieldName = elem.fieldNameStringData();
- if (fieldName == "clearEntries"_sd) {
- uassert(
- ErrorCodes::TypeMismatch,
- str::stream() << "The 'clearEntries' parameter of the $telemetry stage must be a "
- "boolean. Instead found: "
- << typeName(elem.type()),
- elem.type() == BSONType::Bool);
- clearEntries = elem.boolean();
- } else {
- uasserted(ErrorCodes::FailedToParse,
- str::stream()
- << "Unrecognized option '" << fieldName << "' in $telemetry stage.");
- }
- }
+ uassert(ErrorCodes::FailedToParse,
+ str::stream() << kStageName
+ << " parameters object must be empty. Found: " << typeName(spec.type()),
+ spec.embeddedObject().isEmpty());
- return std::make_unique<DocumentSourceTelemetry::LiteParsed>(spec.fieldName(), clearEntries);
+ return std::make_unique<DocumentSourceTelemetry::LiteParsed>(spec.fieldName());
}
boost::intrusive_ptr<DocumentSource> DocumentSourceTelemetry::createFromBson(
@@ -78,48 +61,27 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceTelemetry::createFromBson(
<< " value must be an object. Found: " << typeName(spec.type()),
spec.type() == BSONType::Object);
+ uassert(ErrorCodes::FailedToParse,
+ str::stream() << kStageName
+ << " parameters object must be empty. Found: " << typeName(spec.type()),
+ spec.embeddedObject().isEmpty());
+
const NamespaceString& nss = pExpCtx->ns;
uassert(ErrorCodes::InvalidNamespace,
"$telemetry must be run against the 'admin' database with {aggregate: 1}",
nss.db() == NamespaceString::kAdminDb && nss.isCollectionlessAggregateNS());
- auto clearEntries = false;
-
- for (auto&& elem : spec.embeddedObject()) {
- const auto fieldName = elem.fieldNameStringData();
- if (fieldName == "clearEntries"_sd) {
- uassert(
- ErrorCodes::TypeMismatch,
- str::stream() << "The 'clearEntries' parameter of the $telemetry stage must be a "
- "boolean. Instead found: "
- << typeName(elem.type()),
- elem.type() == BSONType::Bool);
- clearEntries = elem.boolean();
- } else {
- uasserted(ErrorCodes::FailedToParse,
- str::stream()
- << "Unrecognized option '" << fieldName << "' in $telemetry stage.");
- }
- }
-
- return new DocumentSourceTelemetry(pExpCtx, clearEntries);
+ return new DocumentSourceTelemetry(pExpCtx);
}
Value DocumentSourceTelemetry::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {
- return Value{Document{{kStageName, Document{{kClearEntriesFieldName, Value(_clearEntries)}}}}};
+ return Value{Document{{kStageName, Document{}}}};
}
void DocumentSourceTelemetry::buildTelemetryStoreIterator() {
TelemetryStore* telemetryStore = [&]() {
- if (_clearEntries) {
- // Save the telemetry store to a member variable to be destroyed with the document
- // source.
- _telemetryStore = resetTelemetryStore(getContext()->opCtx->getServiceContext());
- return &**_telemetryStore;
- } else {
- return getTelemetryStoreForRead(getContext()->opCtx->getServiceContext()).first;
- }
+ return getTelemetryStoreForRead(getContext()->opCtx->getServiceContext()).first;
}();
// Here we start a new thread which runs until the document source finishes iterating the
diff --git a/src/mongo/db/pipeline/document_source_telemetry.h b/src/mongo/db/pipeline/document_source_telemetry.h
index 7d9bb55997c..d3a7dfd78e2 100644
--- a/src/mongo/db/pipeline/document_source_telemetry.h
+++ b/src/mongo/db/pipeline/document_source_telemetry.h
@@ -45,8 +45,8 @@ public:
static std::unique_ptr<LiteParsed> parse(const NamespaceString& nss,
const BSONElement& spec);
- LiteParsed(std::string parseTimeName, bool clearEntries)
- : LiteParsedDocumentSource(std::move(parseTimeName)), _clearEntries(clearEntries) {}
+ LiteParsed(std::string parseTimeName)
+ : LiteParsedDocumentSource(std::move(parseTimeName)) {}
stdx::unordered_set<NamespaceString> getInvolvedNamespaces() const override {
return stdx::unordered_set<NamespaceString>();
@@ -69,9 +69,6 @@ public:
void assertSupportsMultiDocumentTransaction() const {
transactionNotSupported(kStageName);
}
-
- private:
- const bool _clearEntries;
};
static boost::intrusive_ptr<DocumentSource> createFromBson(
@@ -172,16 +169,13 @@ private:
stdx::condition_variable _waitForEmpty;
};
- DocumentSourceTelemetry(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- bool clearEntries)
- : DocumentSource(kStageName, expCtx), _clearEntries(clearEntries) {}
+ DocumentSourceTelemetry(const boost::intrusive_ptr<ExpressionContext>& expCtx)
+ : DocumentSource(kStageName, expCtx) {}
GetNextResult doGetNext() final;
void buildTelemetryStoreIterator();
- const bool _clearEntries;
-
bool _initialized = false;
/**
diff --git a/src/mongo/db/pipeline/document_source_telemetry_test.cpp b/src/mongo/db/pipeline/document_source_telemetry_test.cpp
index 0d5814c7c1c..9d8f2ad7e26 100644
--- a/src/mongo/db/pipeline/document_source_telemetry_test.cpp
+++ b/src/mongo/db/pipeline/document_source_telemetry_test.cpp
@@ -77,13 +77,6 @@ TEST_F(DocumentSourceTelemetryTest, ShouldFailToParseIfNotRunWithAggregateOne) {
ErrorCodes::InvalidNamespace);
}
-TEST_F(DocumentSourceTelemetryTest, ShouldFailToParseClearEntriesIfNotBoolean) {
- ASSERT_THROWS_CODE(DocumentSourceTelemetry::createFromBson(
- fromjson("{$telemetry: {clearEntries: 1}}").firstElement(), getExpCtx()),
- AssertionException,
- ErrorCodes::TypeMismatch);
-}
-
TEST_F(DocumentSourceTelemetryTest, ShouldFailToParseIfUnrecognisedParameterSpecified) {
ASSERT_THROWS_CODE(DocumentSourceTelemetry::createFromBson(
fromjson("{$telemetry: {foo: true}}").firstElement(), getExpCtx()),
@@ -91,27 +84,11 @@ TEST_F(DocumentSourceTelemetryTest, ShouldFailToParseIfUnrecognisedParameterSpec
ErrorCodes::FailedToParse);
}
-TEST_F(DocumentSourceTelemetryTest, ShouldParseAndSerializeNonDefaultOptionalArguments) {
- auto obj = fromjson("{$telemetry: {clearEntries: true}}");
- auto doc = DocumentSourceTelemetry::createFromBson(obj.firstElement(), getExpCtx());
- auto telemetryOp = static_cast<DocumentSourceTelemetry*>(doc.get());
- auto expected = Document{{"$telemetry", Document{{"clearEntries", true}}}};
- ASSERT_DOCUMENT_EQ(telemetryOp->serialize().getDocument(), expected);
-}
-
-TEST_F(DocumentSourceTelemetryTest, ShouldParseAndSerializeDefaultOptionalArguments) {
- auto obj = fromjson("{$telemetry: {clearEntries: false}}");
- auto doc = DocumentSourceTelemetry::createFromBson(obj.firstElement(), getExpCtx());
- auto telemetryOp = static_cast<DocumentSourceTelemetry*>(doc.get());
- auto expected = Document{{"$telemetry", Document{{"clearEntries", false}}}};
- ASSERT_DOCUMENT_EQ(telemetryOp->serialize().getDocument(), expected);
-}
-
-TEST_F(DocumentSourceTelemetryTest, ShouldSerializeOmittedOptionalArguments) {
+TEST_F(DocumentSourceTelemetryTest, ParseAndSerialize) {
auto obj = fromjson("{$telemetry: {}}");
auto doc = DocumentSourceTelemetry::createFromBson(obj.firstElement(), getExpCtx());
auto telemetryOp = static_cast<DocumentSourceTelemetry*>(doc.get());
- auto expected = Document{{"$telemetry", Document{{"clearEntries", false}}}};
+ auto expected = Document{{"$telemetry", Document{}}};
ASSERT_DOCUMENT_EQ(telemetryOp->serialize().getDocument(), expected);
}
diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl
index c247bdabc47..0b743fc94a3 100644
--- a/src/mongo/db/query/query_knobs.idl
+++ b/src/mongo/db/query/query_knobs.idl
@@ -964,11 +964,11 @@ server_parameters:
cache. This will accept values in either of the following formats:
1. <number>% indicates a percentage of the physical memory available to the process. E.g.: 15%.
2. <number>(MB|GB), indicates the amount of memory in MB or GB. E.g.: 1.5GB, 100MB.
- The default value is 5%, which means 5% of the physical memory available to the process."
+ The default value is 1%, which means 1% of the physical memory available to the process."
set_at: [ startup, runtime ]
cpp_varname: "queryTelemetryStoreSize"
cpp_vartype: synchronized_value<std::string>
- default: "5%"
+ default: "1%"
on_update: telemetry_util::onTelemetryStoreSizeUpdate
validator:
callback: telemetry_util::validateTelemetryStoreSize