1
0
Fork 0

try to force cleanup on shutdown (#8754)

This commit is contained in:
Jan 2019-04-15 12:40:09 +02:00 committed by GitHub
parent 13b2d40aef
commit 340e3c79b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 24 deletions

View File

@ -446,6 +446,8 @@ void DatabaseFeature::stop() {
<< ", keys: " << currentKeysCount
<< ", queries: " << currentQueriesCount;
#endif
vocbase->stop();
vocbase->processCollections(
[](LogicalCollection* collection) {
// no one else must modify the collection's status while we are in

View File

@ -698,7 +698,6 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
unregisterCollection(collection);
locker.unlock();
writeLocker.unlock();
TRI_ASSERT(engine != nullptr);
@ -744,19 +743,29 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
return TRI_ERROR_NO_ERROR;
}
/// @brief stop operations in this vocbase. must be called prior to
/// shutdown to clean things up
void TRI_vocbase_t::stop() {
try {
// stop replication
if (_replicationApplier != nullptr) {
_replicationApplier->stopAndJoin();
}
// mark all cursors as deleted so underlying collections can be freed soon
_cursorRepository->garbageCollect(true);
// mark all collection keys as deleted so underlying collections can be freed
// soon
_collectionKeys->garbageCollect(true);
} catch (...) {
// we are calling this on shutdown, and always want to go on from here
}
}
/// @brief closes a database and all collections
void TRI_vocbase_t::shutdown() {
// stop replication
if (_replicationApplier != nullptr) {
_replicationApplier->stopAndJoin();
}
// mark all cursors as deleted so underlying collections can be freed soon
_cursorRepository->garbageCollect(true);
// mark all collection keys as deleted so underlying collections can be freed
// soon
_collectionKeys->garbageCollect(true);
this->stop();
std::vector<std::shared_ptr<arangodb::LogicalCollection>> collections;
@ -1528,7 +1537,7 @@ std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::createView(arangodb::veloc
if (!res.ok()) {
unregisterView(*view);
THROW_ARANGO_EXCEPTION_MESSAGE(res.errorNumber(), res.errorMessage());
THROW_ARANGO_EXCEPTION(res);
}
} catch (...) {
unregisterView(*view);

View File

@ -241,6 +241,10 @@ struct TRI_vocbase_t {
/// @brief returns whether the database is the system database
bool isSystem() const { return name() == TRI_VOC_SYSTEM_DATABASE; }
/// @brief stop operations in this vocbase. must be called prior to
/// shutdown to clean things up
void stop();
/// @brief closes a database and all collections
void shutdown();

View File

@ -47,7 +47,7 @@ function UnloadCollection (collection) {
if (++tries >= 20) {
break;
}
if (tries == 1) {
if (tries === 1) {
printf("Trying to unload collection '%s', current status: %s\n", collection.name(), collection.status());
}
@ -465,7 +465,7 @@ function CheckCollection (collection, issues, details) {
printf(" identifier: %s\n", collection._id);
printf("\n");
var datafiles = collection.datafiles();
let datafiles = collection.datafiles();
printf("Datafiles\n");
printf(" # of journals: %d\n", datafiles.journals.length);
@ -473,15 +473,15 @@ function CheckCollection (collection, issues, details) {
printf(" # of datafiles: %d\n", datafiles.datafiles.length);
printf("\n");
for (var i = 0; i < datafiles.journals.length; ++i) {
for (let i = 0; i < datafiles.journals.length; ++i) {
CheckDatafile(collection, "journal", datafiles.journals[i], issues, details);
}
for (var i = 0; i < datafiles.datafiles.length; ++i) {
for (let i = 0; i < datafiles.datafiles.length; ++i) {
CheckDatafile(collection, "datafile", datafiles.datafiles[i], issues, details);
}
for (var i = 0; i < datafiles.compactors.length; ++i) {
for (let i = 0; i < datafiles.compactors.length; ++i) {
CheckDatafile(collection, "compactor", datafiles.compactors[i], issues, details);
}
}
@ -524,7 +524,7 @@ function main (argv) {
return s;
};
if (databases.length == 0) {
if (databases.length === 0) {
printf("No databases available. Exiting\n");
return;
}
@ -542,12 +542,12 @@ function main (argv) {
while (true) {
line = console.getline();
if (line == "") {
if (line === "") {
printf("Exiting. Please wait.\n");
return;
}
else {
var l = parseInt(line);
let l = parseInt(line);
if (l < 0 || l >= databases.length || l === null || l === undefined || isNaN(l)) {
printf("Please select a number between 0 and %d: ", databases.length - 1);
@ -563,7 +563,7 @@ function main (argv) {
var collections = internal.db._collections();
if (collections.length == 0) {
if (collections.length === 0) {
printf("No collections available. Exiting\n");
return;
}
@ -587,7 +587,7 @@ function main (argv) {
while (true) {
line = console.getline();
if (line == "") {
if (line === "") {
printf("Exiting. Please wait.\n");
return;
}
@ -600,7 +600,7 @@ function main (argv) {
break;
}
else {
var l = parseInt(line);
let l = parseInt(line);
if (l < 0 || l >= collections.length || l === null || l === undefined || isNaN(l)) {
printf("Please select a number between 0 and %d: ", collections.length - 1);