mirror of https://gitee.com/bigwinds/arangodb
try to fix a race in TTL thread shutdown (#9096)
This commit is contained in:
parent
6ceb6209ed
commit
c23c50c069
|
@ -1,7 +1,9 @@
|
||||||
devel
|
devel
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* updated ArangoDB Starter 0.14.4
|
* fix a race in TTL thread deactivation/shutdown
|
||||||
|
|
||||||
|
* updated ArangoDB starter to 0.14.4
|
||||||
|
|
||||||
* fixed internal issue #3919: The web UI is now using precompiled ejs templates.
|
* fixed internal issue #3919: The web UI is now using precompiled ejs templates.
|
||||||
|
|
||||||
|
|
|
@ -515,14 +515,31 @@ void TtlFeature::allowRunning(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!value && _thread != nullptr) {
|
if (value) {
|
||||||
// wait until TTL operations have finished
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForThreadWork();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TtlFeature::waitForThreadWork() {
|
||||||
|
while (true) {
|
||||||
|
{
|
||||||
|
MUTEX_LOCKER(locker, _threadMutex);
|
||||||
|
|
||||||
|
if (_thread == nullptr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
_thread->wakeup();
|
_thread->wakeup();
|
||||||
|
|
||||||
while (_thread->isCurrentlyWorking()) {
|
if (!_thread->isCurrentlyWorking()) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TtlFeature::activate() {
|
void TtlFeature::activate() {
|
||||||
|
@ -548,13 +565,7 @@ void TtlFeature::deactivate() {
|
||||||
_active = false;
|
_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_thread != nullptr) {
|
waitForThreadWork();
|
||||||
_thread->wakeup();
|
|
||||||
|
|
||||||
while (_thread->isCurrentlyWorking()) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_TOPIC("898a7", DEBUG, Logger::TTL) << "deactivated TTL background thread";
|
LOG_TOPIC("898a7", DEBUG, Logger::TTL) << "deactivated TTL background thread";
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,9 @@ class TtlFeature final : public application_features::ApplicationFeature {
|
||||||
/// but the user has set _active to false.
|
/// but the user has set _active to false.
|
||||||
void allowRunning(bool value);
|
void allowRunning(bool value);
|
||||||
|
|
||||||
|
/// @brief wait until the TTL thread has successfully stopped working
|
||||||
|
void waitForThreadWork();
|
||||||
|
|
||||||
/// @brief turn expiring/removing outdated documents on
|
/// @brief turn expiring/removing outdated documents on
|
||||||
void activate();
|
void activate();
|
||||||
/// @brief turn expiring/removing outdated documents off, blocks until
|
/// @brief turn expiring/removing outdated documents off, blocks until
|
||||||
|
|
Loading…
Reference in New Issue