Skip to content

Commit

Permalink
Add more logs to see how global config works
Browse files Browse the repository at this point in the history
  • Loading branch information
hfu94 committed May 7, 2024
1 parent c3871aa commit ef84b35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion fdbclient/GlobalConfig.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ void GlobalConfig::erase(KeyRangeRef range) {
// Updates local copy of global configuration by reading the entire key-range
// from storage (proxied through the GrvProxies).
ACTOR Future<Void> GlobalConfig::refresh(GlobalConfig* self, Version lastKnown) {
// TraceEvent trace(SevInfo, "GlobalConfigRefresh");
TraceEvent trace(SevInfo, "GlobalConfigRefresh");
std::cout << "Hfu5Refresh lastKnown=" << lastKnown << std::endl;
self->erase(KeyRangeRef(""_sr, "\xff"_sr));

state Backoff backoff(CLIENT_KNOBS->GLOBAL_CONFIG_REFRESH_BACKOFF, CLIENT_KNOBS->GLOBAL_CONFIG_REFRESH_MAX_BACKOFF);
Expand All @@ -170,12 +171,16 @@ ACTOR Future<Void> GlobalConfig::refresh(GlobalConfig* self, Version lastKnown)
&GrvProxyInterface::refreshGlobalConfig,
GlobalConfigRefreshRequest{ lastKnown }),
CLIENT_KNOBS->GLOBAL_CONFIG_REFRESH_TIMEOUT));
std::cout << "Hfu5Refresh reply received, lastKnown=" << lastKnown << std::endl;
for (const auto& kv : reply.result) {
KeyRef systemKey = kv.key.removePrefix(globalConfigKeysPrefix);
std::cout << "SystemKey=" << systemKey.toString() << std::endl;
self->insert(systemKey, kv.value);
}
return Void();
} catch (Error& e) {
TraceEvent("Hfu5GlobalConfigError").error(e);
std::cout << "Hfu5Refresh Error, lastKnown=" << lastKnown << " Error is " << e.code() << std::endl;
wait(backoff.onError());
}
}
Expand All @@ -187,6 +192,7 @@ ACTOR Future<Void> GlobalConfig::updater(GlobalConfig* self, const ClientDBInfo*
loop {
try {
if (self->initialized.canBeSet()) {
std::cout << "Hfu5 Initialize updater" << std::endl;
wait(self->cx->onConnected());

wait(self->refresh(self, -1));
Expand All @@ -206,6 +212,8 @@ ACTOR Future<Void> GlobalConfig::updater(GlobalConfig* self, const ClientDBInfo*
// This process missed too many global configuration
// history updates or the protocol version changed, so it
// must re-read the entire configuration range.
std::cout << "Hfu5 GlobalConfig refresh" << std::endl;

wait(self->refresh(self, history.back().version));
if (dbInfo->history.size() > 0) {
self->lastUpdate = dbInfo->history.back().version;
Expand All @@ -215,6 +223,7 @@ ACTOR Future<Void> GlobalConfig::updater(GlobalConfig* self, const ClientDBInfo*
// version. Mutation history should already be stored in
// ascending version order.
for (const auto& vh : history) {
std::cout << "Hfu5 GlobalConfig Apply Version=" << vh.version << " lastUpdate=" << self->lastUpdate << std::endl;
if (vh.version <= self->lastUpdate) {
continue; // already applied this mutation
}
Expand Down
2 changes: 1 addition & 1 deletion fdbclient/NativeAPI.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8966,7 +8966,7 @@ Reference<TransactionLogInfo> Transaction::createTrLogInfoProbabilistically(cons
if (!cx->isError()) {
double sampleRate =
cx->globalConfig->get<double>(fdbClientInfoTxnSampleRate, std::numeric_limits<double>::infinity());
std::cout << "Reading raw sample rate" << sampleRate << " isInf=" << (std::isinf(sampleRate) ? "True" : "False") << std::endl;
std::cout << "Reading raw sample rate=" << sampleRate << " isInf=" << (std::isinf(sampleRate) ? "True" : "False") << std::endl;
double clientSamplingProbability =
cx->globalConfig->get<double>(fdbClientInfoTxnSampleRate, CLIENT_KNOBS->CSI_SAMPLING_PROBABILITY);
// std::isinf(sampleRate) ? CLIENT_KNOBS->CSI_SAMPLING_PROBABILITY : sampleRate;
Expand Down
4 changes: 2 additions & 2 deletions fdbclient/include/fdbclient/GlobalConfig.actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class GlobalConfig : NonCopyable {
const T get(KeyRef name, T defaultVal) {
try {
auto configValue = get(name);
std::cout << "Get " << name.toString() << " is Valid=" << (configValue.isValid() ? "True" : "False") << std::endl;
// std::cout << "Get " << name.toString() << " is Valid=" << (configValue.isValid() ? "True" : "False") << std::endl;
if (configValue.isValid()) {
std::cout << "Get " << name.toString() << " hasValue=" << (configValue->value.has_value() ? "True" : "False") << std::endl;
// std::cout << "Get " << name.toString() << " hasValue=" << (configValue->value.has_value() ? "True" : "False") << std::endl;
if (configValue->value.has_value()) {
return std::any_cast<T>(configValue->value);
}
Expand Down

0 comments on commit ef84b35

Please sign in to comment.