diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2023-02-08 22:03:04 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-09 11:23:11 +0000 |
commit | 4185cda9e51154dae02956a3c13f4c8d9cec48d6 (patch) | |
tree | 67677c991fe38b61368ddbcc3b9e97d68ae95321 | |
parent | 7be8b2f04f5d2e487015c4fcb92b7ff6aa81dc57 (diff) | |
download | mongo-4185cda9e51154dae02956a3c13f4c8d9cec48d6.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 13471a49c9e..32cca0821c1 100644 --- a/src/mongo/db/query/telemetry.cpp +++ b/src/mongo/db/query/telemetry.cpp @@ -183,6 +183,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>> |