mirror of https://gitee.com/bigwinds/arangodb
removed some TRI_collection_t instances
This commit is contained in:
parent
61d11fd71c
commit
672255fad7
|
@ -84,19 +84,14 @@ void MMFilesCleanupThread::run() {
|
|||
for (auto& collection : collections) {
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
TRI_collection_t* document = nullptr;
|
||||
{
|
||||
READ_LOCKER(readLocker, collection->_lock);
|
||||
document = collection->_collection;
|
||||
if (collection->_collection == nullptr) {
|
||||
// collection currently not loaded
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (document == nullptr) {
|
||||
// collection currently not loaded
|
||||
continue;
|
||||
}
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
// we're the only ones that can unload the collection, so using
|
||||
// the collection pointer outside the lock is ok
|
||||
|
||||
|
@ -106,7 +101,7 @@ void MMFilesCleanupThread::run() {
|
|||
collection->cleanupIndexes();
|
||||
}
|
||||
|
||||
cleanupCollection(collection, document);
|
||||
cleanupCollection(collection);
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
@ -149,18 +144,18 @@ void MMFilesCleanupThread::cleanupCursors(bool force) {
|
|||
}
|
||||
|
||||
/// @brief checks all datafiles of a collection
|
||||
void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collection,
|
||||
TRI_collection_t* document) {
|
||||
void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collection) {
|
||||
// unload operations can normally only be executed when a collection is fully
|
||||
// garbage collected
|
||||
bool unloadChecked = false;
|
||||
|
||||
// but if we are in server shutdown, we can force unloading of collections
|
||||
bool isInShutdown = application_features::ApplicationServer::isStopping();
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
// loop until done
|
||||
|
||||
while (true) {
|
||||
auto ditches = document->ditches();
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "Basics/ConditionVariable.h"
|
||||
#include "Basics/Thread.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
@ -58,8 +57,7 @@ class MMFilesCleanupThread final : public Thread {
|
|||
void cleanupCursors(bool force);
|
||||
|
||||
/// @brief checks all datafiles of a collection
|
||||
void cleanupCollection(arangodb::LogicalCollection* collection,
|
||||
TRI_collection_t* document);
|
||||
void cleanupCollection(arangodb::LogicalCollection* collection);
|
||||
|
||||
private:
|
||||
TRI_vocbase_t* _vocbase;
|
||||
|
|
|
@ -347,7 +347,6 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
|
|||
TRI_voc_fid_t const targetFid = context._compactor->fid();
|
||||
|
||||
TRI_df_marker_type_t const type = marker->getType();
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
// new or updated document
|
||||
if (type == TRI_DF_MARKER_VPACK_DOCUMENT) {
|
||||
|
@ -372,7 +371,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
|
|||
|
||||
// write to compactor files
|
||||
TRI_df_marker_t* result;
|
||||
int res = copyMarker(document, context._compactor, marker, &result);
|
||||
int res = copyMarker(context._compactor, marker, &result);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// TODO: dont fail but recover from this state
|
||||
|
@ -400,7 +399,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
|
|||
if (context._keepDeletions) {
|
||||
// write to compactor files
|
||||
TRI_df_marker_t* result;
|
||||
int res = copyMarker(document, context._compactor, marker, &result);
|
||||
int res = copyMarker(context._compactor, marker, &result);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// TODO: dont fail but recover from this state
|
||||
|
@ -970,8 +969,7 @@ uint64_t MMFilesCompactorThread::getNumberOfDocuments(LogicalCollection* collect
|
|||
}
|
||||
|
||||
/// @brief write a copy of the marker into the datafile
|
||||
int MMFilesCompactorThread::copyMarker(TRI_collection_t* document,
|
||||
TRI_datafile_t* compactor, TRI_df_marker_t const* marker,
|
||||
int MMFilesCompactorThread::copyMarker(TRI_datafile_t* compactor, TRI_df_marker_t const* marker,
|
||||
TRI_df_marker_t** result) {
|
||||
int res = compactor->reserveElement(marker->getSize(), result, 0);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "Basics/Thread.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
struct TRI_datafile_t;
|
||||
struct TRI_df_marker_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
@ -94,8 +93,7 @@ class MMFilesCompactorThread final : public Thread {
|
|||
uint64_t getNumberOfDocuments(LogicalCollection* collection);
|
||||
|
||||
/// @brief write a copy of the marker into the datafile
|
||||
int copyMarker(TRI_collection_t* document,
|
||||
TRI_datafile_t* compactor, TRI_df_marker_t const* marker,
|
||||
int copyMarker(TRI_datafile_t* compactor, TRI_df_marker_t const* marker,
|
||||
TRI_df_marker_t** result);
|
||||
|
||||
/// @brief wait time between compaction runs when idle
|
||||
|
|
|
@ -1227,30 +1227,18 @@ TRI_vocbase_t* MMFilesEngine::openExistingDatabase(TRI_voc_tick_t id, std::strin
|
|||
for (auto const& it : VPackArrayIterator(slice)) {
|
||||
// we found a collection that is still active
|
||||
// FIXME Check if it is correct to free the collection here
|
||||
std::unique_ptr<arangodb::LogicalCollection> c;
|
||||
|
||||
TRI_ASSERT(!it.get("cid").isNone());
|
||||
try {
|
||||
c.reset(StorageEngine::registerCollection(ConditionalWriteLocker::DoLock(),
|
||||
vocbase.get(), it));
|
||||
} catch (...) {
|
||||
// if we caught an exception, c is still a nullptr
|
||||
}
|
||||
arangodb::LogicalCollection* collection = StorageEngine::registerCollection(ConditionalWriteLocker::DoLock(), vocbase.get(), it);
|
||||
|
||||
if (c == nullptr) {
|
||||
LOG(ERR) << "failed to add document collection '" << it.get("name").copyString() << "'";
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_CORRUPTED_COLLECTION);
|
||||
}
|
||||
|
||||
registerCollectionPath(vocbase->id(), c->cid(), c->path());
|
||||
registerCollectionPath(vocbase->id(), collection->cid(), collection->path());
|
||||
|
||||
if (!wasCleanShutdown) {
|
||||
// iterating markers may be time-consuming. we'll only do it if
|
||||
// we have to
|
||||
findMaxTickInJournals(c->path());
|
||||
findMaxTickInJournals(collection->path());
|
||||
}
|
||||
|
||||
LOG(DEBUG) << "added document collection '" << c->name() << "'";
|
||||
LOG(DEBUG) << "added document collection '" << collection->name() << "'";
|
||||
}
|
||||
|
||||
// start cleanup thread
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
struct TRI_df_marker_t;
|
||||
struct TRI_collection_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
|
|
@ -42,8 +42,6 @@ class Transaction;
|
|||
}
|
||||
#endif
|
||||
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
namespace basics {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <velocypack/Buffer.h>
|
||||
|
||||
struct TRI_collection_t;
|
||||
struct TRI_datafile_t;
|
||||
struct TRI_df_marker_t;
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#include "Wal/CollectorCache.h"
|
||||
#include "Wal/Logfile.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
class LogicalCollection;
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include "Wal/Logfile.h"
|
||||
#include "Wal/Marker.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
class DatabaseFeature;
|
||||
|
||||
|
|
Loading…
Reference in New Issue