1
0
Fork 0

try to fix a race in TTL thread shutdown (#9096)

This commit is contained in:
Jan 2019-05-27 11:25:49 +02:00 committed by GitHub
parent 6ceb6209ed
commit c23c50c069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 14 deletions

View File

@ -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.

View File

@ -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";
}

View File

@ -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