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
|
||||
-----
|
||||
|
||||
* 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.
|
||||
|
||||
|
|
|
@ -514,14 +514,31 @@ void TtlFeature::allowRunning(bool value) {
|
|||
_allowRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!value && _thread != nullptr) {
|
||||
// wait until TTL operations have finished
|
||||
_thread->wakeup();
|
||||
|
||||
while (_thread->isCurrentlyWorking()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
if (value) {
|
||||
return;
|
||||
}
|
||||
|
||||
waitForThreadWork();
|
||||
}
|
||||
|
||||
void TtlFeature::waitForThreadWork() {
|
||||
while (true) {
|
||||
{
|
||||
MUTEX_LOCKER(locker, _threadMutex);
|
||||
|
||||
if (_thread == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
_thread->wakeup();
|
||||
|
||||
if (!_thread->isCurrentlyWorking()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,13 +565,7 @@ void TtlFeature::deactivate() {
|
|||
_active = false;
|
||||
}
|
||||
|
||||
if (_thread != nullptr) {
|
||||
_thread->wakeup();
|
||||
|
||||
while (_thread->isCurrentlyWorking()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
}
|
||||
waitForThreadWork();
|
||||
|
||||
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.
|
||||
void allowRunning(bool value);
|
||||
|
||||
/// @brief wait until the TTL thread has successfully stopped working
|
||||
void waitForThreadWork();
|
||||
|
||||
/// @brief turn expiring/removing outdated documents on
|
||||
void activate();
|
||||
/// @brief turn expiring/removing outdated documents off, blocks until
|
||||
|
|
Loading…
Reference in New Issue