1
0
Fork 0

abort waitForSync ops during server shutdown

This commit is contained in:
jsteemann 2017-06-01 17:07:09 +02:00
parent 6b18cc64fe
commit 377431b138
4 changed files with 28 additions and 7 deletions

View File

@ -22,6 +22,7 @@
/// @author Jan Christoph Uhde /// @author Jan Christoph Uhde
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/FileUtils.h" #include "Basics/FileUtils.h"
#include "Basics/MutexLocker.h" #include "Basics/MutexLocker.h"
#include "Basics/ReadLocker.h" #include "Basics/ReadLocker.h"
@ -695,6 +696,10 @@ int MMFilesEngine::getViews(TRI_vocbase_t* vocbase,
} }
void MMFilesEngine::waitForSync(TRI_voc_tick_t tick) { void MMFilesEngine::waitForSync(TRI_voc_tick_t tick) {
if (application_features::ApplicationServer::isStopping()) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_SHUTTING_DOWN);
}
MMFilesLogfileManager::instance()->slots()->waitForTick(tick); MMFilesLogfileManager::instance()->slots()->waitForTick(tick);
} }

View File

@ -762,11 +762,19 @@ MMFilesWalSlotInfoCopy MMFilesLogfileManager::writeSlot(MMFilesWalSlotInfo& slot
// internals of slotInfo.slot to 0 again // internals of slotInfo.slot to 0 again
MMFilesWalSlotInfoCopy copy(slotInfo.slot); MMFilesWalSlotInfoCopy copy(slotInfo.slot);
_slots->returnUsed(slotInfo, wakeUpSynchronizer, waitForSyncRequested, waitUntilSyncDone); int res = _slots->returnUsed(slotInfo, wakeUpSynchronizer, waitForSyncRequested, waitUntilSyncDone);
if (res == TRI_ERROR_NO_ERROR) {
return copy; return copy;
}
return MMFilesWalSlotInfoCopy(res);
} catch (...) { } catch (...) {
// if we don't return the slot we'll run into serious problems later // if we don't return the slot we'll run into serious problems later
_slots->returnUsed(slotInfo, false, false, false); int res = _slots->returnUsed(slotInfo, false, false, false);
if (res != TRI_ERROR_NO_ERROR) {
return MMFilesWalSlotInfoCopy(res);
}
return MMFilesWalSlotInfoCopy(TRI_ERROR_INTERNAL); return MMFilesWalSlotInfoCopy(TRI_ERROR_INTERNAL);
} }

View File

@ -22,6 +22,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "MMFilesWalSlots.h" #include "MMFilesWalSlots.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/ConditionLocker.h" #include "Basics/ConditionLocker.h"
#include "Basics/MutexLocker.h" #include "Basics/MutexLocker.h"
#include "Basics/encoding.h" #include "Basics/encoding.h"
@ -300,7 +301,7 @@ MMFilesWalSlotInfo MMFilesWalSlots::nextUnused(TRI_voc_tick_t databaseId, TRI_vo
} }
/// @brief return a used slot, allowing its synchronization /// @brief return a used slot, allowing its synchronization
void MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchronizer, int MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchronizer,
bool waitForSyncRequested, bool waitUntilSyncDone) { bool waitForSyncRequested, bool waitUntilSyncDone) {
TRI_ASSERT(slotInfo.slot != nullptr); TRI_ASSERT(slotInfo.slot != nullptr);
// waitUntilSyncDone does not make sense without waitForSyncRequested // waitUntilSyncDone does not make sense without waitForSyncRequested
@ -328,8 +329,15 @@ void MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchr
} }
if (waitUntilSyncDone) { if (waitUntilSyncDone) {
// on shutdown, return early
if (application_features::ApplicationServer::isStopping()) {
return TRI_ERROR_SHUTTING_DOWN;
}
waitForTick(tick); waitForTick(tick);
} }
return TRI_ERROR_NO_ERROR;
} }
/// @brief get the next synchronisable region /// @brief get the next synchronisable region

View File

@ -103,7 +103,7 @@ class MMFilesWalSlots {
TRI_voc_cid_t collectionId, uint32_t size); TRI_voc_cid_t collectionId, uint32_t size);
/// @brief return a used slot, allowing its synchronization /// @brief return a used slot, allowing its synchronization
void returnUsed(MMFilesWalSlotInfo&, bool wakeUpSynchronizer, int returnUsed(MMFilesWalSlotInfo&, bool wakeUpSynchronizer,
bool waitForSyncRequested, bool waitUntilSyncDone); bool waitForSyncRequested, bool waitUntilSyncDone);
/// @brief get the next synchronizable region /// @brief get the next synchronizable region