10000 APM-132: Clean up collection statuses by jsteemann · Pull Request #14539 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

APM-132: Clean up collection statuses #14539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
devel
-----

* Remove collection statuses "new born", "loading", "unloading" and "unloaded".
These statuses were last relevant with the MMFiles storage engine, when it
was important to differentiate which collections are present in main memory
memory and which aren't. With the RocksDB storage engine, all that was
automatically handled anyway, and the statuses were not important anymore.

The change removes the "Load" and "Unload" buttons for collections from the
web interface. All collections in the web interface will be marked as
"loaded" permanently.

This change also obsoletes the `load()` and `unload()` calls for collections
as well as their HTTP API equivalents. The APIs will remain in place for now
but are changed to no-ops. They will removed eventually in a future version
of ArangoDB. This will be announced separately.

* Include K_SHORTEST_PATHS and SHORTEST_PATH execution nodes in AQL query
memory usage accounting. The memory used by these execution node types was
previously not tracked against the configured query memory limit.
Expand Down
15 changes: 1 addition & 14 deletions arangod/ClusterEngine/ClusterCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,8 @@ ErrorCode ClusterCollection::close() {
for (auto it : _indexes) {
it->unload();
}
return TRI_ERROR_NO_ERROR;
}

void ClusterCollection::load() {
RECURSIVE_READ_LOCKER(_indexesLock, _indexesLockWriteOwner);
for (auto it : _indexes) {
it->load();
}
}

void ClusterCollection::unload() {
RECURSIVE_READ_LOCKER(_indexesLock, _indexesLockWriteOwner);
for (auto it : _indexes) {
it->unload();
}
return TRI_ERROR_NO_ERROR;
}

RevisionId ClusterCollection::revision(transaction::Methods* trx) const {
Expand Down
2 changes: 0 additions & 2 deletions arangod/ClusterEngine/ClusterCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class ClusterCollection final : public PhysicalCollection {

/// @brief closes an open collection
ErrorCode close() override;
void load() override;
void unload() override;

RevisionId revision(arangodb::transaction::Methods* trx) const override;
uint64_t numberDocuments(transaction::Methods* trx) const override;
Expand Down
28 changes: 0 additions & 28 deletions arangod/RocksDBEngine/RocksDBCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,34 +285,6 @@ ErrorCode RocksDBCollection::close() {
return TRI_ERROR_NO_ERROR;
}

void RocksDBCollection::load() {
if (_cacheEnabled) {
createCache();
if (_cache) {
uint64_t numDocs = _meta.numberDocuments();
if (numDocs > 0) {
_cache->sizeHint(static_cast<uint64_t>(0.3 * numDocs));
}
}
}
RECURSIVE_READ_LOCKER(_indexesLock, _indexesLockWriteOwner);
for (auto it : _indexes) {
it->load();
}
}

void RocksDBCollection::unload() {
WRITE_LOCKER(guard, _exclusiveLock);
if (useCache()) {
destroyCache();
TRI_ASSERT(_cache.get() == nullptr);
}
RECURSIVE_READ_LOCKER(_indexesLock, _indexesLockWriteOwner);
for (auto it : _indexes) {
it->unload();
}
}

/// return bounds for all documents
RocksDBKeyBounds RocksDBCollection::bounds() const {
return RocksDBKeyBounds::CollectionDocuments(objectId());
Expand Down
2 changes: 0 additions & 2 deletions arangod/RocksDBEngine/RocksDBCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class RocksDBCollection final : public RocksDBMetaCollection {

/// @brief closes an open collection
ErrorCode close() override;
void load() override;
void unload() override;

/// return bounds for all documents
RocksDBKeyBounds bounds() const override;
Expand Down
2 changes: 0 additions & 2 deletions arangod/StorageEngine/PhysicalCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class PhysicalCollection {
virtual void getPropertiesVPack(velocypack::Builder&) const = 0;

virtual ErrorCode close() = 0;
virtual void load() = 0;
virtual void unload() = 0;

// @brief Return the number of documents in this collection
virtual uint64_t numberDocuments(transaction::Methods* trx) const = 0;
Expand Down
25 changes: 3 additions & 22 deletions arangod/VocBase/LogicalCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,11 @@ namespace {

static std::string translateStatus(TRI_vocbase_col_status_e status) {
switch (status) {
case TRI_VOC_COL_STATUS_UNLOADED:
return "unloaded";
case TRI_VOC_COL_STATUS_LOADED:
return "loaded";
case TRI_VOC_COL_STATUS_UNLOADING:
return "unloading";
case TRI_VOC_COL_STATUS_DELETED:
return "deleted";
case TRI_VOC_COL_STATUS_LOADING:
return "loading";
case TRI_VOC_COL_STATUS_CORRUPTED:
case TRI_VOC_COL_STATUS_NEW_BORN:
default:
return "unknown";
}
Expand Down Expand Up @@ -585,16 +578,9 @@ Result LogicalCollection::rename(std::string&& newName) {
break;
}

switch (_status) {
case TRI_VOC_COL_STATUS_UNLOADED:
case TRI_VOC_COL_STATUS_LOADED:
case TRI_VOC_COL_STATUS_UNLOADING:
case TRI_VOC_COL_STATUS_LOADING: {
break;
}
default:
// Unknown status
return TRI_ERROR_INTERNAL;
if (_status != TRI_VOC_COL_STATUS_LOADED) {
// Unknown status
return TRI_ERROR_INTERNAL;
}

auto doSync = databaseFeature.forceSyncProperties();
Expand Down Expand Up @@ -625,14 +611,9 @@ Result LogicalCollection::rename(std::string&& newName) {
}

ErrorCode LogicalCollection::close() {
// This was unload() in 3.0
return getPhysical()->close();
}

void LogicalCollection::load() { _physical->load(); }

void LogicalCollection::unload() { _physical->unload(); }

arangodb::Result LogicalCollection::drop() {
// make sure collection has been closed
this->close();
Expand Down
3 changes: 0 additions & 3 deletions arangod/VocBase/LogicalCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ class LogicalCollection : public LogicalDataSource {
bool allowUserKeys() const;

// SECTION: Modification Functions
void load();
void unload();

virtual arangodb::Result drop() override;
virtual Result rename(std::string&& name) override;
virtual void setStatus(TRI_vocbase_col_status_e);
Expand Down
50 changes: 8 additions & 42 deletions arangod/VocBase/Methods/Collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,50 +583,16 @@ void Collections::createSystemCollectionProperties(std::string const& collection
return res;
}

Result Collections::load(TRI_vocbase_t& vocbase, LogicalCollection* coll) {
TRI_ASSERT(coll != nullptr);

if (ServerState::instance()->isCoordinator()) {
#ifdef USE_ENTERPRISE
auto& feature = vocbase.server().getFeature<ClusterFeature>();
return ULColCoordinatorEnterprise(feature, coll->vocbase().name(),
std::to_string(coll->id().id()),
TRI_VOC_COL_STATUS_LOADED);
#else
auto& ci = vocbase.server().getFeature<ClusterFeature>().clusterInfo();
return ci.setCollectionStatusCoordinator(coll->vocbase().name(),
std::to_string(coll->id().id()),
TRI_VOC_COL_STATUS_LOADED);
#endif
}

auto ctx = transaction::V8Context::CreateWhenRequired(vocbase, true);
SingleCollectionTransaction trx(ctx, *coll, AccessMode::Type::READ);
Result res = trx.begin();

if (res.fail()) {
return res;
}

return trx.finish(res);
Result Collections::load(TRI_vocbase_t& /*vocbase*/, LogicalCollection* /*coll*/) {
// load doesn't do anything from ArangoDB 3.9 onwards, and the method
// may be deleted in a future version
return {};
}

Result Collections::unload(TRI_vocbase_t* vocbase, LogicalCollection* coll) {
if (ServerState::instance()->isCoordinator()) {
#ifdef USE_ENTERPRISE
auto& feature = vocbase->server().getFeature<ClusterFeature>();
return ULColCoordinatorEnterprise(feature, vocbase->name(),
std::to_string(coll->id().id()),
TRI_VOC_COL_STATUS_UNLOADED);
#else
auto& ci = vocbase->server().getFeature<ClusterFeature>().clusterInfo();
return ci.setCollectionStatusCoordinator(vocbase->name(),
std::to_string(coll->id().id()),
TRI_VOC_COL_STATUS_UNLOADED);
#endif
}

return vocbase->unloadCollection(coll, false);
Result Collections::unload(TRI_vocbase_t* /*vocbase*/, LogicalCollection* /*coll*/) {
// unload doesn't do anything from ArangoDB 3.9 onwards, and the method
// may be deleted in a future version
return {};
}

Result Collections::properties(Context& ctxt, VPackBuilder& builder) {
Expand Down
5 changes: 1 addition & 4 deletions arangod/VocBase/Methods/Collections.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ struct Collections {
/// @brief filters properties for collection creation
static arangodb::velocypack::Builder filterInput(arangodb::velocypack::Slice slice);
};
#ifdef USE_ENTERPRISE
Result ULColCoordinatorEnterprise(ClusterFeature& feature, std::string const& databaseName,
std::string const& collectionCID,
TRI_vocbase_col_status_e status);

#ifdef USE_ENTERPRISE
Result DropColCoordinatorEnterprise(LogicalCollection* collection, bool allowDropSystem);
#endif
} // namespace methods
Expand Down
Loading
0