mirror of https://gitee.com/bigwinds/arangodb
abort waitForSync ops during server shutdown
This commit is contained in:
parent
6b18cc64fe
commit
377431b138
|
@ -22,6 +22,7 @@
|
|||
/// @author Jan Christoph Uhde
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
|
@ -695,6 +696,10 @@ int MMFilesEngine::getViews(TRI_vocbase_t* vocbase,
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -762,11 +762,19 @@ MMFilesWalSlotInfoCopy MMFilesLogfileManager::writeSlot(MMFilesWalSlotInfo& slot
|
|||
// internals of slotInfo.slot to 0 again
|
||||
MMFilesWalSlotInfoCopy copy(slotInfo.slot);
|
||||
|
||||
_slots->returnUsed(slotInfo, wakeUpSynchronizer, waitForSyncRequested, waitUntilSyncDone);
|
||||
return copy;
|
||||
int res = _slots->returnUsed(slotInfo, wakeUpSynchronizer, waitForSyncRequested, waitUntilSyncDone);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
return copy;
|
||||
}
|
||||
return MMFilesWalSlotInfoCopy(res);
|
||||
} catch (...) {
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "MMFilesWalSlots.h"
|
||||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/encoding.h"
|
||||
|
@ -300,8 +301,8 @@ MMFilesWalSlotInfo MMFilesWalSlots::nextUnused(TRI_voc_tick_t databaseId, TRI_vo
|
|||
}
|
||||
|
||||
/// @brief return a used slot, allowing its synchronization
|
||||
void MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchronizer,
|
||||
bool waitForSyncRequested, bool waitUntilSyncDone) {
|
||||
int MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchronizer,
|
||||
bool waitForSyncRequested, bool waitUntilSyncDone) {
|
||||
TRI_ASSERT(slotInfo.slot != nullptr);
|
||||
// waitUntilSyncDone does not make sense without waitForSyncRequested
|
||||
TRI_ASSERT(!waitUntilSyncDone || waitForSyncRequested);
|
||||
|
@ -328,8 +329,15 @@ void MMFilesWalSlots::returnUsed(MMFilesWalSlotInfo& slotInfo, bool wakeUpSynchr
|
|||
}
|
||||
|
||||
if (waitUntilSyncDone) {
|
||||
// on shutdown, return early
|
||||
if (application_features::ApplicationServer::isStopping()) {
|
||||
return TRI_ERROR_SHUTTING_DOWN;
|
||||
}
|
||||
|
||||
waitForTick(tick);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief get the next synchronisable region
|
||||
|
|
|
@ -103,8 +103,8 @@ class MMFilesWalSlots {
|
|||
TRI_voc_cid_t collectionId, uint32_t size);
|
||||
|
||||
/// @brief return a used slot, allowing its synchronization
|
||||
void returnUsed(MMFilesWalSlotInfo&, bool wakeUpSynchronizer,
|
||||
bool waitForSyncRequested, bool waitUntilSyncDone);
|
||||
int returnUsed(MMFilesWalSlotInfo&, bool wakeUpSynchronizer,
|
||||
bool waitForSyncRequested, bool waitUntilSyncDone);
|
||||
|
||||
/// @brief get the next synchronizable region
|
||||
MMFilesWalSyncRegion getSyncRegion();
|
||||
|
|
Loading…
Reference in New Issue