diff --git a/arangod/Indexes/SkiplistIndex.cpp b/arangod/Indexes/SkiplistIndex.cpp index 208a2277d9..17d2f6e31a 100644 --- a/arangod/Indexes/SkiplistIndex.cpp +++ b/arangod/Indexes/SkiplistIndex.cpp @@ -876,7 +876,7 @@ int SkiplistIndex::remove(arangodb::Transaction*, TRI_doc_mptr_t const* doc, } int SkiplistIndex::unload() { - _skiplistIndex->truncate(); + _skiplistIndex->truncate(true); return TRI_ERROR_NO_ERROR; } diff --git a/arangod/StorageEngine/MMFilesCollection.cpp b/arangod/StorageEngine/MMFilesCollection.cpp index 52a3d4d72d..efb1436c38 100644 --- a/arangod/StorageEngine/MMFilesCollection.cpp +++ b/arangod/StorageEngine/MMFilesCollection.cpp @@ -56,16 +56,6 @@ MMFilesCollection::MMFilesCollection(LogicalCollection* collection) MMFilesCollection::~MMFilesCollection() { close(); - - for (auto& it : _datafiles) { - delete it; - } - for (auto& it : _journals) { - delete it; - } - for (auto& it : _compactors) { - delete it; - } } TRI_voc_rid_t MMFilesCollection::revision() const { @@ -83,14 +73,23 @@ int64_t MMFilesCollection::initialCount() const { int MMFilesCollection::close() { // close compactor files closeDatafiles(_compactors); + for (auto& it : _compactors) { + delete it; + } _compactors.clear(); // close journal files closeDatafiles(_journals); + for (auto& it : _journals) { + delete it; + } _journals.clear(); // close datafiles closeDatafiles(_datafiles); + for (auto& it : _datafiles) { + delete it; + } _datafiles.clear(); return TRI_ERROR_NO_ERROR; diff --git a/arangod/StorageEngine/MMFilesEngine.cpp b/arangod/StorageEngine/MMFilesEngine.cpp index dfa79636df..10b1ea1c05 100644 --- a/arangod/StorageEngine/MMFilesEngine.cpp +++ b/arangod/StorageEngine/MMFilesEngine.cpp @@ -1856,10 +1856,9 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase, LogicalCollection* col filename = newName; } - TRI_datafile_t* datafile = - TRI_OpenDatafile(filename, ignoreErrors); + std::unique_ptr df(TRI_OpenDatafile(filename, ignoreErrors)); - if (datafile == nullptr) { + if (df == nullptr) { LOG_TOPIC(ERR, Logger::DATAFILES) << "cannot open datafile '" << filename << "': " << TRI_last_error(); @@ -1868,7 +1867,8 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase, LogicalCollection* col break; } - all.emplace_back(datafile); + all.emplace_back(df.get()); + TRI_datafile_t* datafile = df.release(); // check the document header char const* ptr = datafile->_data; diff --git a/arangod/VocBase/datafile.cpp b/arangod/VocBase/datafile.cpp index 410e31dde2..98d57c5d8b 100644 --- a/arangod/VocBase/datafile.cpp +++ b/arangod/VocBase/datafile.cpp @@ -1895,7 +1895,7 @@ int TRI_datafile_t::close() { } if (_state == TRI_DF_STATE_CLOSED) { - LOG(WARN) << "closing an already closed datafile '" << getName() << "'"; + LOG(TRACE) << "closing an already closed datafile '" << getName() << "'"; return TRI_ERROR_NO_ERROR; } diff --git a/lib/Basics/SkipList.h b/lib/Basics/SkipList.h index 8a9da897de..4c6c564ba0 100644 --- a/lib/Basics/SkipList.h +++ b/lib/Basics/SkipList.h @@ -172,10 +172,10 @@ class SkipList { ////////////////////////////////////////////////////////////////////////////// ~SkipList() { - truncate(); + truncate(false); } - void truncate() { + void truncate(bool createStartNode) { Node* p; Node* next; @@ -193,9 +193,12 @@ class SkipList { _memoryUsed = sizeof(SkipList); _nrUsed = 0; - _start = allocNode(TRI_SKIPLIST_MAX_HEIGHT); - // Note that this can throw - _end = _start; + + if (createStartNode) { + _start = allocNode(TRI_SKIPLIST_MAX_HEIGHT); + // Note that this can throw + _end = _start; + } } //////////////////////////////////////////////////////////////////////////////