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