Add parameter and validator

This commit is contained in:
Clarisse Cheah 2023-02-15 02:06:49 +00:00
parent 97ec2c53fe
commit ec2e483944
5 changed files with 48 additions and 1 deletions

View File

@ -64,6 +64,26 @@ Status validateCollectionStatsNamespaces(const std::vector<std::string> value,
return Status::OK();
}
Status validateExtraDiagnostics(const std::vector<std::string> value) {
try {
std::string flagArr[] = { "all", "concurrent_access", "data_validation", "invalid_op", "out_of_order",
"panic", "slow_operation", "visibility" };
for (const auto& diagFlag : value) {
bool exists = std::find(std::begin(flagArr), std::end(flagArr), diagFlag) != std::end(flagArr);
if (!exists) {
return Status(ErrorCodes::BadValue,
fmt::format("'{}' is not a valid flag option", diagFlag));
}
}
} catch (...) {
return exceptionToStatus();
}
return Status::OK();
}
namespace {
class FTDCCollectionStatsCollector final : public FTDCCollectorInterface {

View File

@ -55,4 +55,9 @@ void stopMongoDFTDC();
Status validateCollectionStatsNamespaces(std::vector<std::string> value,
const boost::optional<TenantId>& tenantId);
/**
* Validation callback for extra diagnostics setParameter
*/
Status validateExtraDiagnostics(std::vector<std::string> value);
} // namespace mongo

View File

@ -47,6 +47,7 @@
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
#include <boost/algorithm/string/join.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
@ -363,6 +364,9 @@ WiredTigerKVEngine::WiredTigerKVEngine(OperationContext* opCtx,
if (gWiredTigerEvictionDirtyTargetGB)
ss << "eviction_dirty_target="
<< static_cast<size_t>(gWiredTigerEvictionDirtyTargetGB * 1024) << "MB,";
if (!gWiredTigerExtraDiagnostics.empty())
ss << "extra_diagnostics=["
<< boost::algorithm::join(gWiredTigerExtraDiagnostics, ",") << "],";
if (gWiredTigerEvictionDirtyMaxGB)
ss << "eviction_dirty_trigger=" << static_cast<size_t>(gWiredTigerEvictionDirtyMaxGB * 1024)
<< "MB,";

View File

@ -110,7 +110,7 @@ server_parameters:
cpp_vartype: 'double'
cpp_varname: gWiredTigerEvictionDirtyTargetGB
default: 0
validator:
:
gte: 0.01
lte: 10000
@ -150,6 +150,17 @@ server_parameters:
validator:
gte: 1
wiredTigerExtraDiagnostics:
description: >-
Extra diagnostics that can be enabled in release mode including diagnostic assertions that can cause WiredTiger to abort upon
detected invalid state. Valid options include: ["all", "concurrent_access", "data_validation", "invalid_op", "out_of_order",
"panic", "slow_operation", "visibility"]
set_at: [startup, runtime]
cpp_vartype: 'synchronized_value<std::vector<std::string>>'
cpp_varname: "gwiredTigerExtraDiagnostics"
validator:
callback: validateExtraDiagnostics
wiredTigerFileHandleCloseMinimum:
description: >-
The number of handles open before the WiredTiger file manager will look for handles to close.

View File

@ -146,6 +146,13 @@ private:
std::unique_ptr<OperationContext> _opCtx;
};
TEST_F(WiredTigerUtilMetadataTest, GetMetadataCreateExtraDiagnostics) {
StatusWith<std::string> result =
WiredTigerUtil::getMetadataCreate(getOperationContext(), getURI());
ASSERT_NOT_OK(result.getStatus());
ASSERT_EQUALS(ErrorCodes::NoSuchKey, result.getStatus().code());
}
TEST_F(WiredTigerUtilMetadataTest, GetMetadataCreateInvalid) {
StatusWith<std::string> result =
WiredTigerUtil::getMetadataCreate(getOperationContext(), getURI());