diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2023-02-16 19:25:28 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-16 20:14:28 +0000 |
commit | b52f0ba969808bb44970a028e10b4106d203438a (patch) | |
tree | 7c52bfdd5348ce5ff9ab67f6a2d3c326a1a27413 | |
parent | c73aa5a010d6125417339e4de3de984518e4cdb4 (diff) | |
download | mongo-b52f0ba969808bb44970a028e10b4106d203438a.tar.gz |
SERVER-73735 Fail configuration more gracefully if telemetry is disabled
-rw-r--r-- | jstests/noPassthroughWithMongod/telemetry_configuration.js | 32 | ||||
-rw-r--r-- | src/mongo/db/query/telemetry.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/telemetry_util.h | 13 |
3 files changed, 47 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/telemetry_configuration.js b/jstests/noPassthroughWithMongod/telemetry_configuration.js new file mode 100644 index 00000000000..8d0b6ed68b5 --- /dev/null +++ b/jstests/noPassthroughWithMongod/telemetry_configuration.js @@ -0,0 +1,32 @@ +/** + * Tests that the telemetry store can be resized if it is configured, and cannot be resized if it is + * disabled. + */ +(function() { +"use strict"; + +load("jstests/libs/feature_flag_util.js"); + +if (FeatureFlagUtil.isEnabled(db, "Telemetry")) { + // The feature flag is enabled - make sure the telemetry store can be configured. + const original = assert.commandWorked( + db.adminCommand({getParameter: 1, internalQueryConfigureTelemetryCacheSize: 1})); + assert(original.hasOwnProperty("internalQueryConfigureTelemetryCacheSize"), original); + const originalValue = original.internalQueryConfigureTelemetryCacheSize; + try { + assert.doesNotThrow( + () => db.adminCommand( + {setParameter: 1, internalQueryConfigureTelemetryCacheSize: '2MB'})); + // Other tests verify that resizing actually affects the data structure size. + } finally { + assert.doesNotThrow( + () => db.adminCommand( + {setParameter: 1, internalQueryConfigureTelemetryCacheSize: originalValue})); + } +} else { + // The feature flag is disabled - make sure the telemetry store *cannot* be configured. + assert.commandFailedWithCode( + db.adminCommand({setParameter: 1, internalQueryConfigureTelemetryCacheSize: '2MB'}), + 7373500); +} +}()); diff --git a/src/mongo/db/query/telemetry.cpp b/src/mongo/db/query/telemetry.cpp index 78d7511cc6d..11b80caf3fa 100644 --- a/src/mongo/db/query/telemetry.cpp +++ b/src/mongo/db/query/telemetry.cpp @@ -141,6 +141,8 @@ ServiceContext::ConstructorActionRegisterer telemetryStoreManagerRegisterer{ // featureFlags are not allowed to be changed at runtime. Therefore it's not an issue // to not create a telemetry store in ConstructorActionRegisterer at start up with the // flag off - because the flag can not be turned on at any point afterwards. + telemetry_util::telemetryStoreOnParamChangeUpdater(serviceCtx) = + std::make_unique<telemetry_util::NoChangesAllowedTelemetryParamUpdater>(); return; } diff --git a/src/mongo/db/query/telemetry_util.h b/src/mongo/db/query/telemetry_util.h index 0aedd95e26e..133d45f1338 100644 --- a/src/mongo/db/query/telemetry_util.h +++ b/src/mongo/db/query/telemetry_util.h @@ -60,6 +60,19 @@ public: }; /** + * A stub implementation that does not allow changing any parameters - to be used if the telemetry + * store is disabled and cannot be re-enabled without restarting, as with a feature flag. + */ +class NoChangesAllowedTelemetryParamUpdater : public OnParamChangeUpdater { +public: + void updateCacheSize(ServiceContext* serviceCtx, memory_util::MemorySize memSize) final { + uasserted(7373500, + "Cannot configure telemetry store - it is currently disabled and a restart is " + "required to activate."); + } +}; + +/** * Decorated accessor to the 'OnParamChangeUpdater' stored in 'ServiceContext'. */ extern const Decorable<ServiceContext>::Decoration<std::unique_ptr<OnParamChangeUpdater>> |