1
0
Fork 0

removed some TRI_collection_t instances

This commit is contained in:
jsteemann 2016-08-30 13:01:34 +02:00
parent 61d11fd71c
commit 672255fad7
10 changed files with 19 additions and 48 deletions

View File

@ -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();

View File

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

View File

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

View File

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

View File

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

View File

@ -33,7 +33,6 @@
#include <velocypack/velocypack-aliases.h>
struct TRI_df_marker_t;
struct TRI_collection_t;
struct TRI_vocbase_t;
namespace arangodb {

View File

@ -42,8 +42,6 @@ class Transaction;
}
#endif
struct TRI_collection_t;
namespace arangodb {
namespace basics {

View File

@ -33,6 +33,7 @@
#include <velocypack/Buffer.h>
struct TRI_collection_t;
struct TRI_datafile_t;
struct TRI_df_marker_t;

View File

@ -35,8 +35,6 @@
#include "Wal/CollectorCache.h"
#include "Wal/Logfile.h"
struct TRI_collection_t;
namespace arangodb {
class LogicalCollection;

View File

@ -33,8 +33,6 @@
#include "Wal/Logfile.h"
#include "Wal/Marker.h"
struct TRI_collection_t;
namespace arangodb {
class DatabaseFeature;