diff --git a/arangod/VocBase/cleanup.cpp b/arangod/VocBase/cleanup.cpp index e46d3f650c..3340f0b200 100644 --- a/arangod/VocBase/cleanup.cpp +++ b/arangod/VocBase/cleanup.cpp @@ -98,6 +98,7 @@ static void CleanupDocumentCollection (TRI_vocbase_col_t* collection, container->_numBarrierElements > 0) { // did not find anything at the head of the barrier list or found an element marker // this means we must exit and cannot throw away datafiles and can unload collections + TRI_UnlockSpin(&container->_lock); return; } @@ -131,12 +132,18 @@ static void CleanupDocumentCollection (TRI_vocbase_col_t* collection, if (! TRI_IsFullyCollectedDocumentCollection(document)) { bool isDeleted = false; - // if there is still some collection to perform, check if the collection was deleted already + // if there is still some garbage collection to perform, + // check if the collection was deleted already if (TRI_TRY_READ_LOCK_STATUS_VOCBASE_COL(collection)) { isDeleted = (collection->_status == TRI_VOC_COL_STATUS_DELETED); TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection); } + if (! isDeleted && TRI_IsDeletedVocBase(collection->_vocbase)) { + // the collection was not marked as deleted, but the database was + isDeleted = true; + } + if (! isDeleted) { // collection is not fully collected and still undeleted - postpone the unload return; diff --git a/arangod/VocBase/vocbase.cpp b/arangod/VocBase/vocbase.cpp index 5ebc6d02ad..66c8ae1df8 100644 --- a/arangod/VocBase/vocbase.cpp +++ b/arangod/VocBase/vocbase.cpp @@ -2336,6 +2336,18 @@ void TRI_ReleaseCollectionVocBase (TRI_vocbase_t* vocbase, TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the vocbase has been marked as deleted +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_IsDeletedVocBase (TRI_vocbase_t* vocbase) { + TRI_LockSpin(&vocbase->_usage._lock); + bool isDeleted = vocbase->_usage._isDeleted; + TRI_UnlockSpin(&vocbase->_usage._lock); + + return isDeleted; +} + //////////////////////////////////////////////////////////////////////////////// /// @brief increase the reference counter for a database //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/VocBase/vocbase.h b/arangod/VocBase/vocbase.h index bbd1fa12fb..f7bbe04ecd 100644 --- a/arangod/VocBase/vocbase.h +++ b/arangod/VocBase/vocbase.h @@ -600,6 +600,12 @@ TRI_vocbase_col_t* TRI_UseCollectionByNameVocBase (TRI_vocbase_t*, void TRI_ReleaseCollectionVocBase (TRI_vocbase_t*, TRI_vocbase_col_t*); +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the vocbase has been marked as deleted +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_IsDeletedVocBase (TRI_vocbase_t*); + //////////////////////////////////////////////////////////////////////////////// /// @brief increase the reference counter for a database ////////////////////////////////////////////////////////////////////////////////