mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-03 03:41:53 +08:00
simplify sim_validation verification to only involve maximum bound
This commit is contained in:
parent
9a18cc8f41
commit
4c942cc4e3
@ -25,7 +25,7 @@
|
||||
|
||||
// used for simulation validations
|
||||
static std::map<std::string, int64_t> validationData;
|
||||
static std::map<std::string, double> validationData2;
|
||||
static std::map<int64_t, double> validationData2;
|
||||
static std::set<UID> disabledMachines;
|
||||
|
||||
void debug_setVersionCheckEnabled(UID uid, bool enabled) {
|
||||
@ -128,71 +128,27 @@ bool debug_isCheckRelocationDuration() {
|
||||
void debug_setCheckRelocationDuration(bool check) {
|
||||
checkRelocationDuration = check;
|
||||
}
|
||||
void debug_advanceVersionTimestamp(int64_t version, double minTime, double maxTime) {
|
||||
debug_advanceVersionMinTimestamp(version, minTime);
|
||||
debug_advanceVersionMaxTimestamp(version, maxTime);
|
||||
}
|
||||
|
||||
void debug_advanceTime(int64_t version, double t, const char* suffix) {
|
||||
auto& entry = validationData2[std::to_string(version) + suffix];
|
||||
if (t > entry) {
|
||||
entry = t;
|
||||
}
|
||||
}
|
||||
|
||||
void debug_advanceVersionMinTimestamp(int64_t version, double t) {
|
||||
void debug_advanceVersionTimestamp(int64_t version, double t) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
return;
|
||||
debug_advanceTime(version, t, "min");
|
||||
}
|
||||
|
||||
void debug_advanceVersionMaxTimestamp(int64_t version, double t) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
return;
|
||||
debug_advanceTime(version, t, "max");
|
||||
}
|
||||
|
||||
bool debug_checkPartVersionTime(int64_t version,
|
||||
double t,
|
||||
std::string context,
|
||||
std::string minormax,
|
||||
Severity sev = SevError) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
return false;
|
||||
if (!validationData2.count(std::to_string(version) + minormax)) {
|
||||
TraceEvent(SevWarn, (context + "UnknownTime").c_str())
|
||||
.detail("VersionChecking", version)
|
||||
.detail("TimeChecking", t);
|
||||
return false;
|
||||
}
|
||||
int sign = minormax == "min" ? 1 : -1;
|
||||
if (t * sign < validationData2[std::to_string(version) + minormax] * sign) {
|
||||
TraceEvent(sev, (context + "DurabilityError").c_str())
|
||||
.detail("VersionChecking", version)
|
||||
.detail("TimeChecking", t)
|
||||
.detail("MinMaxChecking", minormax)
|
||||
.detail("MinTime", validationData2[std::to_string(version) + "min"])
|
||||
.detail("MaxTime", validationData2[std::to_string(version) + "max"]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
validationData2[version] = t;
|
||||
}
|
||||
|
||||
bool debug_checkVersionTime(int64_t version, double t, std::string context, Severity sev) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
return false;
|
||||
return debug_checkPartVersionTime(version, t, context, "min", sev) ||
|
||||
debug_checkPartVersionTime(version, t, context, "max", sev);
|
||||
}
|
||||
|
||||
bool debug_checkVersionMinTime(int64_t version, double t, std::string context, Severity sev) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
if (!validationData2.count(version)) {
|
||||
TraceEvent(SevWarn, (context + "UnknownTime").c_str())
|
||||
.detail("VersionChecking", version)
|
||||
.detail("TimeChecking", t);
|
||||
return false;
|
||||
return debug_checkPartVersionTime(version, t, context, "min", sev);
|
||||
}
|
||||
|
||||
bool debug_checkVersionMaxTime(int64_t version, double t, std::string context, Severity sev) {
|
||||
if (!g_network->isSimulated() || g_simulator.extraDB)
|
||||
return false;
|
||||
return debug_checkPartVersionTime(version, t, context, "max", sev);
|
||||
}
|
||||
if (t > validationData2[version]) {
|
||||
TraceEvent(sev, (context + "DurabilityError").c_str())
|
||||
.detail("VersionChecking", version)
|
||||
.detail("TimeChecking", t)
|
||||
.detail("MaxTime", validationData2[version]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -48,12 +48,7 @@ bool debug_checkMaxRestoredVersion(UID id, int64_t version, std::string context,
|
||||
bool debug_isCheckRelocationDuration();
|
||||
void debug_setCheckRelocationDuration(bool check);
|
||||
|
||||
void debug_advanceVersionTimestamp(int64_t version, double minTime, double maxTime);
|
||||
void debug_advanceVersionMinTimestamp(int64_t version, double t);
|
||||
void debug_advanceVersionMaxTimestamp(int64_t version, double t);
|
||||
|
||||
void debug_advanceVersionTimestamp(int64_t version, double t);
|
||||
bool debug_checkVersionTime(int64_t version, double t, std::string context, Severity sev = SevError);
|
||||
bool debug_checkVersionMinTime(int64_t version, double t, std::string context, Severity sev = SevError);
|
||||
bool debug_checkVersionMaxTime(int64_t version, double t, std::string context, Severity sev = SevError);
|
||||
|
||||
#endif
|
||||
|
@ -1251,10 +1251,10 @@ ACTOR Future<Void> serveLiveCommittedVersion(Reference<MasterData> self) {
|
||||
if (req.version > self->liveCommittedVersion) {
|
||||
auto curTime = now();
|
||||
// add debug here to change liveCommittedVersion to time bound of now()
|
||||
debug_advanceVersionTimestamp(
|
||||
self->liveCommittedVersion, 0, curTime + CLIENT_KNOBS->MAX_VERSION_CACHE_LAG);
|
||||
debug_advanceVersionTimestamp(self->liveCommittedVersion,
|
||||
curTime + CLIENT_KNOBS->MAX_VERSION_CACHE_LAG);
|
||||
// also add req.version but with no time bound
|
||||
debug_advanceVersionTimestamp(req.version, 0, std::numeric_limits<double>::max());
|
||||
debug_advanceVersionTimestamp(req.version, std::numeric_limits<double>::max());
|
||||
self->liveCommittedVersion = req.version;
|
||||
self->databaseLocked = req.locked;
|
||||
self->proxyMetadataVersion = req.metadataVersion;
|
||||
|
Loading…
x
Reference in New Issue
Block a user