8000 Delete broken DB Precond by maierlars · Pull Request #10468 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Delete broken DB Precond #10468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions arangod/Agency/Supervision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,14 +1280,16 @@ void Supervision::workJobs() {
}
}


bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID, uint64_t wantedRebootID) {
bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID,
uint64_t wantedRebootID, bool& coordinatorFound) {
// check if the coordinator exists in health
std::string const& health = serverHealth(coordinatorID);
LOG_TOPIC("44432", DEBUG, Logger::SUPERVISION)
<< "verifyCoordinatorRebootID: coordinatorID="
<< coordinatorID << " health=" << health;

// if the server is not found, health is an empty string
coordinatorFound = health.empty();
if (health != "GOOD" && health != "BAD") {
return false;
}
Expand All @@ -1300,7 +1302,9 @@ bool Supervision::verifyCoordinatorRebootID(std::string const& coordinatorID, ui
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>();
{
VPackArrayBuilder trxs(envelope.get());
Expand Down Expand Up @@ -1329,10 +1333,15 @@ void Supervision::deleteBrokenDatabase(std::string const& database, std::string
}
{
// 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::DatabaseCoordinatorRebootId, VPackValue(rebootID));
envelope->add(_agencyPrefix + planDBPrefix + database + "/" + StaticStrings::DatabaseCoordinator, VPackValue(coordinatorID));

{
VPackObjectBuilder precondition(envelope.get(), _agencyPrefix + healthPrefix + "/" + coordinatorID);
envelope->add("oldEmpty", VPackValue(!coordinatorFound));
}
}
}
}
Expand Down Expand Up @@ -1371,9 +1380,11 @@ void Supervision::checkBrokenCreatedDatabases() {
std::pair<std::string, bool> coordinatorID = db->hasAsString(StaticStrings::DatabaseCoordinator);

bool keepDatabase = true;
bool coordinatorFound = false;

if (rebootID.second && coordinatorID.second) {
keepDatabase = verifyCoordinatorRebootID(coordinatorID.first, rebootID.first);
keepDatabase = verifyCoordinatorRebootID(coordinatorID.first,
rebootID.first, coordinatorFound);
// incomplete data, should not happen
} else {
// v---- Please note this awesome log-id
Expand All @@ -1386,7 +1397,7 @@ void Supervision::checkBrokenCreatedDatabases() {
LOG_TOPIC("fe522", INFO, Logger::SUPERVISION)
<< "checkBrokenCreatedDatabases: removing skeleton database with name " << dbpair.first;
// delete this database and all of its collections
deleteBrokenDatabase(dbpair.first, coordinatorID.first, rebootID.first);
deleteBrokenDatabase(dbpair.first, coordinatorID.first, rebootID.first, coordinatorFound);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions arangod/Agency/Supervision.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ class Supervision : public arangodb::CriticalThread {

bool handleJobs();
void handleShutdown();
bool verifyCoordinatorRebootID(std::string const& coordinatorID, uint64_t wantedRebootID);
void deleteBrokenDatabase(std::string const& database, std::string const& coordinatorID, uint64_t rebootID);
bool verifyCoordinatorRebootID(std::string const& coordinatorID,
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
void fixPrototypeChain(VPackBuilder&);
Expand Down
0