mirror of https://gitee.com/bigwinds/arangodb
Port latest shutdown hanger bug to 3.5. (#10121)
This commit is contained in:
parent
c067e17bb6
commit
2201381da9
|
@ -34,7 +34,7 @@ size_t const CollectionKeysRepository::MaxCollectCount = 32;
|
|||
/// @brief create a collection keys repository
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CollectionKeysRepository::CollectionKeysRepository() : _lock(), _keys() {
|
||||
CollectionKeysRepository::CollectionKeysRepository() : _lock(), _keys(), _stopped(false) {
|
||||
_keys.reserve(64);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,9 @@ CollectionKeysRepository::~CollectionKeysRepository() {
|
|||
|
||||
void CollectionKeysRepository::store(std::unique_ptr<arangodb::CollectionKeys> keys) {
|
||||
MUTEX_LOCKER(mutexLocker, _lock);
|
||||
_keys.emplace(keys->id(), std::move(keys));
|
||||
if (!_stopped) {
|
||||
_keys.emplace(keys->id(), std::move(keys));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Mutex.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Utils/CollectionKeys.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
|
@ -90,6 +91,15 @@ class CollectionKeysRepository {
|
|||
|
||||
bool garbageCollect(bool force);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief stop further stores, this is used on shutdown
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void stopStores() {
|
||||
MUTEX_LOCKER(mutexLocker, _lock);
|
||||
_stopped = true;
|
||||
}
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief mutex for the repository
|
||||
|
@ -108,6 +118,13 @@ class CollectionKeysRepository {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static size_t const MaxCollectCount;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief stopped flag, indicating that no more CollectionKeys can be
|
||||
/// stored
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _stopped;
|
||||
};
|
||||
} // namespace arangodb
|
||||
|
||||
|
|
|
@ -760,6 +760,7 @@ void TRI_vocbase_t::stop() {
|
|||
// soon, we have to retry, since some of these collection keys might currently
|
||||
// still being in use:
|
||||
auto lastTime = TRI_microtime();
|
||||
_collectionKeys->stopStores();
|
||||
while (true) {
|
||||
if (!_collectionKeys->garbageCollect(true)) {
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue