Add knob value changes to fdbdecode
E.g., HTTP_VERBOSE_LEVEL, and HTTP_REQUEST_AWS_V4_HEADER knobs.
This commit is contained in:
parent
017709aec6
commit
2532ac5882
|
@ -46,6 +46,7 @@ enum {
|
||||||
OPT_HEX_KEY_PREFIX,
|
OPT_HEX_KEY_PREFIX,
|
||||||
OPT_BEGIN_VERSION_FILTER,
|
OPT_BEGIN_VERSION_FILTER,
|
||||||
OPT_END_VERSION_FILTER,
|
OPT_END_VERSION_FILTER,
|
||||||
|
OPT_KNOB,
|
||||||
OPT_HELP
|
OPT_HELP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ CSimpleOpt::SOption gConverterOptions[] = { { OPT_CONTAINER, "-r", SO_REQ_SEP },
|
||||||
{ OPT_HEX_KEY_PREFIX, "--hex-prefix", SO_REQ_SEP },
|
{ OPT_HEX_KEY_PREFIX, "--hex-prefix", SO_REQ_SEP },
|
||||||
{ OPT_BEGIN_VERSION_FILTER, "--begin-version-filter", SO_REQ_SEP },
|
{ OPT_BEGIN_VERSION_FILTER, "--begin-version-filter", SO_REQ_SEP },
|
||||||
{ OPT_END_VERSION_FILTER, "--end-version-filter", SO_REQ_SEP },
|
{ OPT_END_VERSION_FILTER, "--end-version-filter", SO_REQ_SEP },
|
||||||
|
{ OPT_KNOB, "--knob-", SO_REQ_SEP },
|
||||||
{ OPT_HELP, "-?", SO_NONE },
|
{ OPT_HELP, "-?", SO_NONE },
|
||||||
{ OPT_HELP, "-h", SO_NONE },
|
{ OPT_HELP, "-h", SO_NONE },
|
||||||
{ OPT_HELP, "--help", SO_NONE },
|
{ OPT_HELP, "--help", SO_NONE },
|
||||||
|
|
|
@ -26,17 +26,21 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "fdbbackup/BackupTLSConfig.h"
|
#include "fdbbackup/BackupTLSConfig.h"
|
||||||
|
#include "fdbclient/BuildFlags.h"
|
||||||
|
#include "fdbbackup/FileConverter.h"
|
||||||
#include "fdbclient/BackupAgent.actor.h"
|
#include "fdbclient/BackupAgent.actor.h"
|
||||||
#include "fdbclient/BackupContainer.h"
|
#include "fdbclient/BackupContainer.h"
|
||||||
#include "fdbbackup/FileConverter.h"
|
|
||||||
#include "fdbclient/CommitTransaction.h"
|
#include "fdbclient/CommitTransaction.h"
|
||||||
#include "fdbclient/FDBTypes.h"
|
#include "fdbclient/FDBTypes.h"
|
||||||
|
#include "fdbclient/IKnobCollection.h"
|
||||||
|
#include "fdbclient/Knobs.h"
|
||||||
#include "fdbclient/MutationList.h"
|
#include "fdbclient/MutationList.h"
|
||||||
|
#include "flow/ArgParseUtil.h"
|
||||||
#include "flow/IRandom.h"
|
#include "flow/IRandom.h"
|
||||||
#include "flow/Trace.h"
|
#include "flow/Trace.h"
|
||||||
#include "flow/flow.h"
|
#include "flow/flow.h"
|
||||||
#include "flow/serialize.h"
|
#include "flow/serialize.h"
|
||||||
#include "fdbclient/BuildFlags.h"
|
|
||||||
#include "flow/actorcompiler.h" // has to be last include
|
#include "flow/actorcompiler.h" // has to be last include
|
||||||
|
|
||||||
#define SevDecodeInfo SevVerbose
|
#define SevDecodeInfo SevVerbose
|
||||||
|
@ -73,11 +77,13 @@ void printDecodeUsage() {
|
||||||
" --list-only Print file list and exit.\n"
|
" --list-only Print file list and exit.\n"
|
||||||
" -k KEY_PREFIX Use the prefix for filtering mutations\n"
|
" -k KEY_PREFIX Use the prefix for filtering mutations\n"
|
||||||
" --hex-prefix HEX_PREFIX\n"
|
" --hex-prefix HEX_PREFIX\n"
|
||||||
" The prefix specified in HEX format, e.g., \\x05\\x01.\n"
|
" The prefix specified in HEX format, e.g., \"\\\\x05\\\\x01\".\n"
|
||||||
" --begin-version-filter BEGIN_VERSION\n"
|
" --begin-version-filter BEGIN_VERSION\n"
|
||||||
" The version range's begin version (inclusive) for filtering.\n"
|
" The version range's begin version (inclusive) for filtering.\n"
|
||||||
" --end-version-filter END_VERSION\n"
|
" --end-version-filter END_VERSION\n"
|
||||||
" The version range's end version (exclusive) for filtering.\n"
|
" The version range's end version (exclusive) for filtering.\n"
|
||||||
|
" --knob-KNOBNAME KNOBVALUE\n"
|
||||||
|
" Changes a knob value. KNOBNAME should be lowercase."
|
||||||
"\n";
|
"\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +103,8 @@ struct DecodeParams {
|
||||||
Version beginVersionFilter = 0;
|
Version beginVersionFilter = 0;
|
||||||
Version endVersionFilter = std::numeric_limits<Version>::max();
|
Version endVersionFilter = std::numeric_limits<Version>::max();
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string>> knobs;
|
||||||
|
|
||||||
// Returns if [begin, end) overlap with the filter range
|
// Returns if [begin, end) overlap with the filter range
|
||||||
bool overlap(Version begin, Version end) const {
|
bool overlap(Version begin, Version end) const {
|
||||||
// Filter [100, 200), [50,75) [200, 300)
|
// Filter [100, 200), [50,75) [200, 300)
|
||||||
|
@ -130,8 +138,39 @@ struct DecodeParams {
|
||||||
if (!prefix.empty()) {
|
if (!prefix.empty()) {
|
||||||
s.append(", KeyPrefix: ").append(printable(KeyRef(prefix)));
|
s.append(", KeyPrefix: ").append(printable(KeyRef(prefix)));
|
||||||
}
|
}
|
||||||
|
for (const auto& [knob, value] : knobs) {
|
||||||
|
s.append(", KNOB-").append(knob).append(" = ").append(value);
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateKnobs() {
|
||||||
|
auto& g_knobs = IKnobCollection::getMutableGlobalKnobCollection();
|
||||||
|
for (const auto& [knobName, knobValueString] : knobs) {
|
||||||
|
try {
|
||||||
|
auto knobValue = g_knobs.parseKnobValue(knobName, knobValueString);
|
||||||
|
g_knobs.setKnob(knobName, knobValue);
|
||||||
|
} catch (Error& e) {
|
||||||
|
if (e.code() == error_code_invalid_option_value) {
|
||||||
|
std::cerr << "WARNING: Invalid value '" << knobValueString << "' for knob option '" << knobName
|
||||||
|
<< "'\n";
|
||||||
|
TraceEvent(SevWarnAlways, "InvalidKnobValue")
|
||||||
|
.detail("Knob", printable(knobName))
|
||||||
|
.detail("Value", printable(knobValueString));
|
||||||
|
} else {
|
||||||
|
std::cerr << "ERROR: Failed to set knob option '" << knobName << "': " << e.what() << "\n";
|
||||||
|
TraceEvent(SevError, "FailedToSetKnob")
|
||||||
|
.errorUnsuppressed(e)
|
||||||
|
.detail("Knob", printable(knobName))
|
||||||
|
.detail("Value", printable(knobValueString));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
||||||
|
g_knobs.initialize(Randomize::True, IsSimulated::False);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Decode an ASCII string, e.g., "\x15\x1b\x19\x04\xaf\x0c\x28\x0a",
|
// Decode an ASCII string, e.g., "\x15\x1b\x19\x04\xaf\x0c\x28\x0a",
|
||||||
|
@ -256,6 +295,16 @@ int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) {
|
||||||
param->tlsConfig.blobCredentials.push_back(args->OptionArg());
|
param->tlsConfig.blobCredentials.push_back(args->OptionArg());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPT_KNOB: {
|
||||||
|
Optional<std::string> knobName = extractPrefixedArgument("--knob", args->OptionSyntax());
|
||||||
|
if (!knobName.present()) {
|
||||||
|
std::cerr << "ERROR: unable to parse knob option '" << args->OptionSyntax() << "'\n";
|
||||||
|
return FDB_EXIT_ERROR;
|
||||||
|
}
|
||||||
|
param->knobs.emplace_back(knobName.get(), args->OptionArg());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TLS_DISABLED
|
#ifndef TLS_DISABLED
|
||||||
case TLSConfig::OPT_TLS_PLUGIN:
|
case TLSConfig::OPT_TLS_PLUGIN:
|
||||||
args->OptionArg();
|
args->OptionArg();
|
||||||
|
@ -552,6 +601,9 @@ int main(int argc, char** argv) {
|
||||||
StringRef url(param.container_url);
|
StringRef url(param.container_url);
|
||||||
setupNetwork(0, UseMetrics::True);
|
setupNetwork(0, UseMetrics::True);
|
||||||
|
|
||||||
|
// Must be called after setupNetwork() to be effective
|
||||||
|
param.updateKnobs();
|
||||||
|
|
||||||
TraceEvent::setNetworkThread();
|
TraceEvent::setNetworkThread();
|
||||||
openTraceFile(NetworkAddress(), 10 << 20, 500 << 20, param.log_dir, "decode", param.trace_log_group);
|
openTraceFile(NetworkAddress(), 10 << 20, 500 << 20, param.log_dir, "decode", param.trace_log_group);
|
||||||
param.tlsConfig.setupBlobCredentials();
|
param.tlsConfig.setupBlobCredentials();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "fdbclient/json_spirit/json_spirit_writer_template.h"
|
#include "fdbclient/json_spirit/json_spirit_writer_template.h"
|
||||||
#include "fdbclient/json_spirit/json_spirit_reader_template.h"
|
#include "fdbclient/json_spirit/json_spirit_reader_template.h"
|
||||||
|
#include "flow/Error.h"
|
||||||
|
|
||||||
// JSONDoc is a convenient reader/writer class for manipulating JSON documents using "paths".
|
// JSONDoc is a convenient reader/writer class for manipulating JSON documents using "paths".
|
||||||
// Access is done using a "path", which is a string of dot-separated
|
// Access is done using a "path", which is a string of dot-separated
|
||||||
|
|
Loading…
Reference in New Issue