1
0
Fork 0

Added precondition to ensure that server is still as seen before. (#10468)

This commit is contained in:
Lars Maier 2019-11-21 09:21:36 +01:00 committed by Max Neunhöffer
parent 3090e49258
commit 51af263960
2 changed files with 21 additions and 8 deletions

View File

@ -1280,14 +1280,16 @@ void Supervision::workJobs() {
} }
} }
bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID,
bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID, uint64_t wantedRebootID) { uint64_t wantedRebootID, bool& coordinatorFound) {
// check if the coordinator exists in health // check if the coordinator exists in health
std::string const& health = serverHealth(coordinatorID); std::string const& health = serverHealth(coordinatorID);
LOG_TOPIC("44432", DEBUG, Logger::SUPERVISION) LOG_TOPIC("44432", DEBUG, Logger::SUPERVISION)
<< "verifyCoordinatorRebootID: coordinatorID=" << "verifyCoordinatorRebootID: coordinatorID="
<< coordinatorID << " health=" << health; << coordinatorID << " health=" << health;
// if the server is not found, health is an empty string // if the server is not found, health is an empty string
coordinatorFound = health.empty();
if (health != "GOOD" && health != "BAD") { if (health != "GOOD" && health != "BAD") {
return false; return false;
} }
@ -1300,7 +1302,9 @@ bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID, ui
return rebootID.second && rebootID.first == wantedRebootID; return rebootID.second && rebootID.first == wantedRebootID;
} }
void Supervision::deleteBrokenDatabase(std::string const& database, std::string const& coordinatorID, uint64_t rebootID) { void Supervision::deleteBrokenDatabase(std::string const& database,
std::string const& coordinatorID,
uint64_t rebootID, bool coordinatorFound) {
auto envelope = std::make_shared<Builder>(); auto envelope = std::make_shared<Builder>();
{ {
VPackArrayBuilder trxs(envelope.get()); VPackArrayBuilder trxs(envelope.get());
@ -1329,10 +1333,15 @@ void Supervision::deleteBrokenDatabase(std::string const& database, std::string
} }
{ {
// precondition that this database is still in Plan and is building // precondition that this database is still in Plan and is building
VPackObjectBuilder precondition(envelope.get()); VPackObjectBuilder preconditions(envelope.get());
envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseIsBuilding, VPackValue(true)); envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseIsBuilding, VPackValue(true));
envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseCoordinatorRebootId, VPackValue(rebootID)); envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseCoordinatorRebootId, VPackValue(rebootID));
envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseCoordinator, VPackValue(coordinatorID)); envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseCoordinator, VPackValue(coordinatorID));
{
VPackObjectBuilder precondition(envelope.get(), _agencyPrefix + healthPrefix + "/" + coordinatorID);
envelope->add("oldEmpty", VPackValue(!coordinatorFound));
}
} }
} }
} }
@ -1371,9 +1380,11 @@ void Supervision::checkBrokenCreatedDatabases() {
std::pair<std::string, bool> coordinatorID = db->hasAsString(StaticStrings::DatabaseCoordinator); std::pair<std::string, bool> coordinatorID = db->hasAsString(StaticStrings::DatabaseCoordinator);
bool keepDatabase = true; bool keepDatabase = true;
bool coordinatorFound = false;
if (rebootID.second && coordinatorID.second) { if (rebootID.second && coordinatorID.second) {
keepDatabase = verifyCoordinatorRebootID(coordinatorID.first, rebootID.first); keepDatabase = verifyCoordinatorRebootID(coordinatorID.first,
rebootID.first, coordinatorFound);
// incomplete data, should not happen // incomplete data, should not happen
} else { } else {
// v---- Please note this awesome log-id // v---- Please note this awesome log-id
@ -1386,7 +1397,7 @@ void Supervision::checkBrokenCreatedDatabases() {
LOG_TOPIC("fe522", INFO, Logger::SUPERVISION) LOG_TOPIC("fe522", INFO, Logger::SUPERVISION)
<< "checkBrokenCreatedDatabases: removing skeleton database with name " << dbpair.first; << "checkBrokenCreatedDatabases: removing skeleton database with name " << dbpair.first;
// delete this database and all of its collections // delete this database and all of its collections
deleteBrokenDatabase(dbpair.first, coordinatorID.first, rebootID.first); deleteBrokenDatabase(dbpair.first, coordinatorID.first, rebootID.first, coordinatorFound);
} }
} }
} }

View File

@ -188,8 +188,10 @@ class Supervision : public arangodb::CriticalThread {
bool handleJobs(); bool handleJobs();
void handleShutdown(); void handleShutdown();
bool verifyCoordinatorRebootID(std::string const& coordinatorID, uint64_t wantedRebootID); bool verifyCoordinatorRebootID(std::string const& coordinatorID,
void deleteBrokenDatabase(std::string const& database, std::string const& coordinatorID, uint64_t rebootID); uint64_t wantedRebootID, bool& coordinatorFound);
void deleteBrokenDatabase(std::string const& database, std::string const& coordinatorID,
uint64_t rebootID, bool coordinatorFound);
/// @brief Migrate chains of distributeShardsLike to depth 1 /// @brief Migrate chains of distributeShardsLike to depth 1
void fixPrototypeChain(VPackBuilder&); void fixPrototypeChain(VPackBuilder&);