mirror of https://github.com/mongodb/mongo
Add parameter and validator
This commit is contained in:
parent
97ec2c53fe
commit
ec2e483944
|
|
@ -64,6 +64,26 @@ Status validateCollectionStatsNamespaces(const std::vector<std::string> value,
|
||||||
return Status::OK();
|
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 {
|
namespace {
|
||||||
|
|
||||||
class FTDCCollectionStatsCollector final : public FTDCCollectorInterface {
|
class FTDCCollectionStatsCollector final : public FTDCCollectorInterface {
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,9 @@ void stopMongoDFTDC();
|
||||||
Status validateCollectionStatsNamespaces(std::vector<std::string> value,
|
Status validateCollectionStatsNamespaces(std::vector<std::string> value,
|
||||||
const boost::optional<TenantId>& tenantId);
|
const boost::optional<TenantId>& tenantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation callback for extra diagnostics setParameter
|
||||||
|
*/
|
||||||
|
Status validateExtraDiagnostics(std::vector<std::string> value);
|
||||||
|
|
||||||
} // namespace mongo
|
} // namespace mongo
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
|
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
@ -363,6 +364,9 @@ WiredTigerKVEngine::WiredTigerKVEngine(OperationContext* opCtx,
|
||||||
if (gWiredTigerEvictionDirtyTargetGB)
|
if (gWiredTigerEvictionDirtyTargetGB)
|
||||||
ss << "eviction_dirty_target="
|
ss << "eviction_dirty_target="
|
||||||
<< static_cast<size_t>(gWiredTigerEvictionDirtyTargetGB * 1024) << "MB,";
|
<< static_cast<size_t>(gWiredTigerEvictionDirtyTargetGB * 1024) << "MB,";
|
||||||
|
if (!gWiredTigerExtraDiagnostics.empty())
|
||||||
|
ss << "extra_diagnostics=["
|
||||||
|
<< boost::algorithm::join(gWiredTigerExtraDiagnostics, ",") << "],";
|
||||||
if (gWiredTigerEvictionDirtyMaxGB)
|
if (gWiredTigerEvictionDirtyMaxGB)
|
||||||
ss << "eviction_dirty_trigger=" << static_cast<size_t>(gWiredTigerEvictionDirtyMaxGB * 1024)
|
ss << "eviction_dirty_trigger=" << static_cast<size_t>(gWiredTigerEvictionDirtyMaxGB * 1024)
|
||||||
<< "MB,";
|
<< "MB,";
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ server_parameters:
|
||||||
cpp_vartype: 'double'
|
cpp_vartype: 'double'
|
||||||
cpp_varname: gWiredTigerEvictionDirtyTargetGB
|
cpp_varname: gWiredTigerEvictionDirtyTargetGB
|
||||||
default: 0
|
default: 0
|
||||||
validator:
|
:
|
||||||
gte: 0.01
|
gte: 0.01
|
||||||
lte: 10000
|
lte: 10000
|
||||||
|
|
||||||
|
|
@ -150,6 +150,17 @@ server_parameters:
|
||||||
validator:
|
validator:
|
||||||
gte: 1
|
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:
|
wiredTigerFileHandleCloseMinimum:
|
||||||
description: >-
|
description: >-
|
||||||
The number of handles open before the WiredTiger file manager will look for handles to close.
|
The number of handles open before the WiredTiger file manager will look for handles to close.
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,13 @@ private:
|
||||||
std::unique_ptr<OperationContext> _opCtx;
|
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) {
|
TEST_F(WiredTigerUtilMetadataTest, GetMetadataCreateInvalid) {
|
||||||
StatusWith<std::string> result =
|
StatusWith<std::string> result =
|
||||||
WiredTigerUtil::getMetadataCreate(getOperationContext(), getURI());
|
WiredTigerUtil::getMetadataCreate(getOperationContext(), getURI());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue