FastRestore:Cleanup debug code

This commit is contained in:
Meng Xu 2020-04-07 15:56:44 -07:00
parent 0034d6fc85
commit e5b2cd81d5
6 changed files with 26 additions and 30 deletions

View File

@ -253,7 +253,8 @@ struct RestoreAsset {
// Is mutation's begin and end keys are in RestoreAsset's range
bool isInKeyRange(MutationRef mutation) const {
if (mutation.type == MutationRef::ClearRange) {
if (isRangeMutation(mutation)) {
// Range mutation's right side is exclusive
return mutation.param1 >= range.begin && mutation.param2 <= range.end;
} else {
return mutation.param1 >= range.begin && mutation.param1 < range.end;

View File

@ -150,15 +150,8 @@ ACTOR static Future<Void> handleSendMutationVectorRequest(RestoreSendVersionedMu
batchData->counters.receivedMutations += 1;
batchData->counters.receivedAtomicOps += isAtomicOp((MutationRef::Type)mutation.type) ? 1 : 0;
// Sanity check
if (g_network->isSimulated()) {
// TODO: Use asset.isInKeyRange();
if (isRangeMutation(mutation)) {
ASSERT(mutation.param1 >= req.asset.range.begin &&
mutation.param2 <= req.asset.range.end); // Range mutation's right side is exclusive
} else {
ASSERT(mutation.param1 >= req.asset.range.begin && mutation.param1 < req.asset.range.end);
}
}
ASSERT_WE_THINK(req.asset.isInKeyRange(mutation));
// Note: Log and range mutations may be delivered out of order. Can we handle it?
if (mutation.type == MutationRef::SetVersionstampedKey ||
mutation.type == MutationRef::SetVersionstampedValue) {
@ -309,7 +302,8 @@ ACTOR static Future<Void> precomputeMutationsResult(Reference<ApplierBatchData>
.detail("ClearRangeUpperBound", rangeMutation.mutation.param2)
.detail("UsedUpperBound", ub->first);
}
// Q: Can beginKey = endKey and clear beginKey?
// We make the beginKey = endKey for the ClearRange on purpose so that
// we can sanity check ClearRange mutation when we apply it to DB.
MutationRef clearKey(MutationRef::ClearRange, lb->first, lb->first);
lb->second.add(clearKey, rangeMutation.version);
lb++;

View File

@ -322,6 +322,7 @@ ACTOR static Future<Void> loadFilesOnLoaders(Reference<MasterBatchData> batchDat
int paramIdx = 0;
for (auto& file : *files) {
// TODO: Allow empty files in version batch; Filter out them here.
if (loader == loadersInterf.end()) {
loader = loadersInterf.begin();
}

View File

@ -283,6 +283,7 @@ struct RestoreMasterData : RestoreRoleData, public ReferenceCounted<RestoreMaste
} else {
TraceEvent("FastRestoreBuildVersionBatch").detail("FinishAllLogFiles", logIdx).detail("CurBatchIndex", vb.batchIndex).detail("CurBatchSize", vb.size);
if (prevEndVersion < nextVersion) {
// Ensure the last log file is included in version batch
lastLogFile = true;
} else {
break; // Finished all log files
@ -407,7 +408,9 @@ struct RestoreMasterData : RestoreRoleData, public ReferenceCounted<RestoreMaste
}
// Invariant: The last vb endverion should be no smaller than targetVersion
if(maxVBVersion < targetVersion) {
TraceEvent(SevError, "FastRestoreBuildVersionBatch")
// Q: Is the restorable version always less than the maximum version from all backup filenames?
// A: This is true for the raw backup files returned by backup container before we remove the empty files.
TraceEvent(SevWarnAlways, "FastRestoreBuildVersionBatch")
.detail("TargetVersion", targetVersion)
.detail("MaxVersionBatchVersion", maxVBVersion);
}

View File

@ -27,8 +27,11 @@
const std::vector<std::string> RestoreRoleStr = { "Invalid", "Master", "Loader", "Applier" };
int numRoles = RestoreRoleStr.size();
StringRef debugFRKey = LiteralStringRef("0000000000arl");
// Similar to debugMutation(), we use debugFRMutation to track mutations for fast restore systems only.
#if CENABLED(0, NOT_IN_CLEAN)
StringRef debugFRKey = LiteralStringRef("\xff\xff\xff\xff");
// Track any mutation in fast restore that has overlap with debugFRKey
bool debugFRMutation( const char* context, Version version, MutationRef const& mutation ) {
if (mutation.type != mutation.ClearRange && mutation.param1 == debugFRKey) { // Single key mutation
TraceEvent("FastRestoreMutationTracking").detail("At", context).detail("Version", version).detail("MutationType", getTypeString((MutationRef::Type)mutation.type)).detail("Key", mutation.param1).detail("Value", mutation.param2);
@ -39,6 +42,10 @@ bool debugFRMutation( const char* context, Version version, MutationRef const& m
return true;
}
#else
// Default implementation.
bool debugFRMutation( const char* context, Version version, MutationRef const& mutation ) { return false; }
#endif
std::string getRoleStr(RestoreRole role) {
if ((int)role >= numRoles || (int)role < 0) {

View File

@ -201,23 +201,15 @@ bool enableFailures = true;
vector< Standalone<VectorRef<DebugEntryRef>> > debugEntries;
int64_t totalDebugEntriesSize = 0;
#if CENABLED(1, NOT_IN_CLEAN)
StringRef debugKey2 = LiteralStringRef("0000000000ar");
StringRef debugKey = LiteralStringRef("\xff\xff\xff\xff");
StringRef debugKeyBegin = LiteralStringRef("0000000000a");
StringRef debugKeyEnd = LiteralStringRef("z000000000z");
#if CENABLED(0, NOT_IN_CLEAN)
StringRef debugKey = LiteralStringRef("");
StringRef debugKey2 = LiteralStringRef("\xff\xff\xff\xff");
bool debugMutation( const char* context, Version version, MutationRef const& mutation ) {
if ((mutation.type == mutation.SetValue || mutation.type == mutation.AddValue || mutation.type==mutation.DebugKey) && (mutation.param1 == debugKey || mutation.param1 == debugKey2))
TraceEvent("MutationTracking").detail("At", context).detail("Version", version).detail("MutationType", "SetValue").detail("Key", mutation.param1).detail("Value", mutation.param2);
//else if ((mutation.type == mutation.ClearRange || mutation.type == mutation.DebugKeyRange) && ((mutation.param1<=debugKey && mutation.param2>debugKey) || (mutation.param1<=debugKey2 && mutation.param2>debugKey2)))
else if ((mutation.type == mutation.ClearRange || mutation.type == mutation.DebugKeyRange) && (mutation.param1>=debugKeyBegin && mutation.param2<=debugKeyEnd))
TraceEvent("MutationTracking")
.detail("At", context)
.detail("Version", version)
.detail("MutationType", "ClearRange")
.detail("KeyBegin", mutation.param1)
.detail("KeyEnd", mutation.param2);
;//TraceEvent("MutationTracking").detail("At", context).detail("Version", version).detail("MutationType", "SetValue").detail("Key", mutation.param1).detail("Value", mutation.param2);
else if ((mutation.type == mutation.ClearRange || mutation.type == mutation.DebugKeyRange) && ((mutation.param1<=debugKey && mutation.param2>debugKey) || (mutation.param1<=debugKey2 && mutation.param2>debugKey2)))
;//TraceEvent("MutationTracking").detail("At", context).detail("Version", version).detail("MutationType", "ClearRange").detail("KeyBegin", mutation.param1).detail("KeyEnd", mutation.param2);
else
return false;
const char* type =
@ -227,9 +219,7 @@ bool debugMutation( const char* context, Version version, MutationRef const& mut
mutation.type == MutationRef::DebugKeyRange ? "DebugKeyRange" :
mutation.type == MutationRef::DebugKey ? "DebugKey" :
"UnknownMutation";
// printf("DEBUGMUTATION:\t%.6f\t%s\t%s\t%lld\t%s\t%s\t%s\n", now(),
// g_network->getLocalAddress().toString().c_str(), context, version, type, printable(mutation.param1).c_str(),
// printable(mutation.param2).c_str());
printf("DEBUGMUTATION:\t%.6f\t%s\t%s\t%lld\t%s\t%s\t%s\n", now(), g_network->getLocalAddress().toString().c_str(), context, version, type, printable(mutation.param1).c_str(), printable(mutation.param2).c_str());
return true;
}