mirror of https://gitee.com/bigwinds/arangodb
try to force cleanup on shutdown (#8754)
This commit is contained in:
parent
13b2d40aef
commit
340e3c79b0
|
@ -446,6 +446,8 @@ void DatabaseFeature::stop() {
|
||||||
<< ", keys: " << currentKeysCount
|
<< ", keys: " << currentKeysCount
|
||||||
<< ", queries: " << currentQueriesCount;
|
<< ", queries: " << currentQueriesCount;
|
||||||
#endif
|
#endif
|
||||||
|
vocbase->stop();
|
||||||
|
|
||||||
vocbase->processCollections(
|
vocbase->processCollections(
|
||||||
[](LogicalCollection* collection) {
|
[](LogicalCollection* collection) {
|
||||||
// no one else must modify the collection's status while we are in
|
// no one else must modify the collection's status while we are in
|
||||||
|
|
|
@ -698,7 +698,6 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
||||||
unregisterCollection(collection);
|
unregisterCollection(collection);
|
||||||
|
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
writeLocker.unlock();
|
writeLocker.unlock();
|
||||||
|
|
||||||
TRI_ASSERT(engine != nullptr);
|
TRI_ASSERT(engine != nullptr);
|
||||||
|
@ -744,19 +743,29 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
||||||
return TRI_ERROR_NO_ERROR;
|
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
|
/// @brief closes a database and all collections
|
||||||
void TRI_vocbase_t::shutdown() {
|
void TRI_vocbase_t::shutdown() {
|
||||||
// stop replication
|
this->stop();
|
||||||
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);
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<arangodb::LogicalCollection>> collections;
|
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()) {
|
if (!res.ok()) {
|
||||||
unregisterView(*view);
|
unregisterView(*view);
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(res.errorNumber(), res.errorMessage());
|
THROW_ARANGO_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
unregisterView(*view);
|
unregisterView(*view);
|
||||||
|
|
|
@ -241,6 +241,10 @@ struct TRI_vocbase_t {
|
||||||
/// @brief returns whether the database is the system database
|
/// @brief returns whether the database is the system database
|
||||||
bool isSystem() const { return name() == TRI_VOC_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
|
/// @brief closes a database and all collections
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ function UnloadCollection (collection) {
|
||||||
if (++tries >= 20) {
|
if (++tries >= 20) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tries == 1) {
|
if (tries === 1) {
|
||||||
printf("Trying to unload collection '%s', current status: %s\n", collection.name(), collection.status());
|
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(" identifier: %s\n", collection._id);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
var datafiles = collection.datafiles();
|
let datafiles = collection.datafiles();
|
||||||
|
|
||||||
printf("Datafiles\n");
|
printf("Datafiles\n");
|
||||||
printf(" # of journals: %d\n", datafiles.journals.length);
|
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(" # of datafiles: %d\n", datafiles.datafiles.length);
|
||||||
printf("\n");
|
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);
|
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);
|
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);
|
CheckDatafile(collection, "compactor", datafiles.compactors[i], issues, details);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ function main (argv) {
|
||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (databases.length == 0) {
|
if (databases.length === 0) {
|
||||||
printf("No databases available. Exiting\n");
|
printf("No databases available. Exiting\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -542,12 +542,12 @@ function main (argv) {
|
||||||
while (true) {
|
while (true) {
|
||||||
line = console.getline();
|
line = console.getline();
|
||||||
|
|
||||||
if (line == "") {
|
if (line === "") {
|
||||||
printf("Exiting. Please wait.\n");
|
printf("Exiting. Please wait.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var l = parseInt(line);
|
let l = parseInt(line);
|
||||||
|
|
||||||
if (l < 0 || l >= databases.length || l === null || l === undefined || isNaN(l)) {
|
if (l < 0 || l >= databases.length || l === null || l === undefined || isNaN(l)) {
|
||||||
printf("Please select a number between 0 and %d: ", databases.length - 1);
|
printf("Please select a number between 0 and %d: ", databases.length - 1);
|
||||||
|
@ -563,7 +563,7 @@ function main (argv) {
|
||||||
|
|
||||||
|
|
||||||
var collections = internal.db._collections();
|
var collections = internal.db._collections();
|
||||||
if (collections.length == 0) {
|
if (collections.length === 0) {
|
||||||
printf("No collections available. Exiting\n");
|
printf("No collections available. Exiting\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ function main (argv) {
|
||||||
while (true) {
|
while (true) {
|
||||||
line = console.getline();
|
line = console.getline();
|
||||||
|
|
||||||
if (line == "") {
|
if (line === "") {
|
||||||
printf("Exiting. Please wait.\n");
|
printf("Exiting. Please wait.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ function main (argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var l = parseInt(line);
|
let l = parseInt(line);
|
||||||
|
|
||||||
if (l < 0 || l >= collections.length || l === null || l === undefined || isNaN(l)) {
|
if (l < 0 || l >= collections.length || l === null || l === undefined || isNaN(l)) {
|
||||||
printf("Please select a number between 0 and %d: ", collections.length - 1);
|
printf("Please select a number between 0 and %d: ", collections.length - 1);
|
||||||
|
|
Loading…
Reference in New Issue