From aca39415198f45eb916cd5627efad1bb76b21750 Mon Sep 17 00:00:00 2001 From: Josh Slocum Date: Wed, 2 Jun 2021 20:40:00 +0000 Subject: [PATCH] found bug in detecting first test in restart --- fdbserver/CommitProxyServer.actor.cpp | 3 +-- fdbserver/SimulatedCluster.actor.cpp | 29 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index 0fa96678de..8f4a56c61c 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -1275,8 +1275,7 @@ ACTOR Future reply(CommitBatchContext* self) { // self->committedVersion by reporting commit version first before updating self->committedVersion. Otherwise, a // client may get a commit version that the master is not aware of, and next GRV request may get a version less than // self->committedVersion. - TEST(pProxyCommitData->committedVersion.get() > - self->commitVersion); // A later version was reported committed first + TEST(pProxyCommitData->committedVersion.get() > self->commitVersion); // A later version was reported committed first if (self->commitVersion >= pProxyCommitData->committedVersion.get()) { wait(pProxyCommitData->master.reportLiveCommittedVersion.getReply( ReportRawCommittedVersionRequest(self->commitVersion, diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index d32e8491d5..4b7618a194 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -170,7 +170,7 @@ class TestConfig { if (attrib == "maxTLogVersion") { sscanf(value.c_str(), "%d", &maxTLogVersion); } - if (attrib == "restartInfoLocation") { + if (attrib == "restartInfoLocation") { isFirstTestInRestart = true; } } @@ -203,6 +203,23 @@ public: stderrSeverity, machineCount, processesPerMachine, coordinators; Optional config; + bool tomlKeyPresent(const toml::value& data, std::string key) { + if (data.is_table()) { + for (const auto& [k, v] : data.as_table()) { + if (k == key || tomlKeyPresent(v, key)) { + return true; + } + } + } else if (data.is_array()) { + for (const auto& v : data.as_array()) { + if (tomlKeyPresent(v, key)) { + return true; + } + } + } + return false; + } + void readFromConfig(const char* testFile) { if (isIniFile(testFile)) { loadIniFile(testFile); @@ -248,6 +265,10 @@ public: TraceEvent("StderrSeverity").detail("NewSeverity", stderrSeverity.get()); } } + // look for restartInfoLocation to mark isFirstTestInRestart + if (!isFirstTestInRestart) { + isFirstTestInRestart = tomlKeyPresent(file, "restartInfoLocation"); + } } catch (std::exception& e) { std::cerr << e.what() << std::endl; TraceEvent("TOMLParseError").detail("Error", printable(e.what())); @@ -1188,7 +1209,11 @@ void SimulationConfig::generateNormalConfig(const TestConfig& testConfig) { db.grvProxyCount = 1; db.resolverCount = 1; } - int replication_type = testConfig.simpleConfig ? 1 : (std::max(testConfig.minimumReplication, datacenters > 4 ? deterministicRandom()->randomInt(1, 3) : std::min(deterministicRandom()->randomInt(0, 6), 3))); + int replication_type = testConfig.simpleConfig + ? 1 + : (std::max(testConfig.minimumReplication, + datacenters > 4 ? deterministicRandom()->randomInt(1, 3) + : std::min(deterministicRandom()->randomInt(0, 6), 3))); if (testConfig.config.present()) { set_config(testConfig.config.get()); } else {