mirror of https://gitee.com/bigwinds/arangodb
turn off the in-memory cache on agency nodes, as it is not needed there (#6742)
This commit is contained in:
parent
8f67a162d8
commit
ea915d3d69
|
@ -12,6 +12,11 @@ devel
|
|||
v3.4.0-rc.3 (XXXX-XX-XX)
|
||||
------------------------
|
||||
|
||||
* disable in-memory cache for edge and traversal data on agency nodes, as it
|
||||
is not needed there
|
||||
|
||||
* include forward-ported diagnostic options for debugging LDAP connections
|
||||
|
||||
* support installation of ArangoDB on Windows into directories with multibyte
|
||||
character filenames on Windows platforms that used a non-UTF8-codepage
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "Basics/process-utils.h"
|
||||
#include "Cache/CacheManagerFeatureThreads.h"
|
||||
#include "Cache/Manager.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "ProgramOptions/ProgramOptions.h"
|
||||
#include "ProgramOptions/Section.h"
|
||||
|
@ -87,7 +88,7 @@ void CacheManagerFeature::validateOptions(
|
|||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
|
||||
if (_cacheSize < (CacheManagerFeature::minRebalancingInterval)) {
|
||||
if (_rebalancingInterval < (CacheManagerFeature::minRebalancingInterval)) {
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME)
|
||||
<< "invalid value for `--cache.rebalancing-interval', need at least "
|
||||
<< (CacheManagerFeature::minRebalancingInterval);
|
||||
|
@ -96,6 +97,12 @@ void CacheManagerFeature::validateOptions(
|
|||
}
|
||||
|
||||
void CacheManagerFeature::start() {
|
||||
if (ServerState::instance()->isAgent()) {
|
||||
// we intentionally do not activate the cache on an agency node, as it
|
||||
// is not needed there
|
||||
return;
|
||||
}
|
||||
|
||||
auto scheduler = SchedulerFeature::SCHEDULER;
|
||||
auto postFn = [scheduler](std::function<void()> fn) -> bool {
|
||||
scheduler->post(fn, false);
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace arangodb {
|
|||
class CacheManagerFeature final
|
||||
: public application_features::ApplicationFeature {
|
||||
public:
|
||||
// note that the cache is optional and that MANAGER can be a nullptr!
|
||||
static cache::Manager* MANAGER;
|
||||
|
||||
explicit CacheManagerFeature(application_features::ApplicationServer& server);
|
||||
|
@ -57,4 +58,4 @@ class CacheManagerFeature final
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -44,8 +44,9 @@ using namespace arangodb::graph;
|
|||
TraverserDocumentCache::TraverserDocumentCache(aql::Query* query)
|
||||
: TraverserCache(query), _cache(nullptr) {
|
||||
auto cacheManager = CacheManagerFeature::MANAGER;
|
||||
TRI_ASSERT(cacheManager != nullptr);
|
||||
_cache = cacheManager->createCache(cache::CacheType::Plain);
|
||||
if (cacheManager != nullptr) {
|
||||
_cache = cacheManager->createCache(cache::CacheType::Plain);
|
||||
}
|
||||
}
|
||||
|
||||
TraverserDocumentCache::~TraverserDocumentCache() {
|
||||
|
@ -165,4 +166,3 @@ void TraverserDocumentCache::insertDocument(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,8 @@ RocksDBCollection::RocksDBCollection(
|
|||
_cachePresent(false),
|
||||
_cacheEnabled(!collection.system() &&
|
||||
basics::VelocyPackHelper::readBooleanValue(
|
||||
info, "cacheEnabled", false)) {
|
||||
info, "cacheEnabled", false) &&
|
||||
CacheManagerFeature::MANAGER != nullptr) {
|
||||
TRI_ASSERT(!ServerState::instance()->isCoordinator());
|
||||
VPackSlice s = info.get("isVolatile");
|
||||
if (s.isBoolean() && s.getBoolean()) {
|
||||
|
@ -139,7 +140,8 @@ RocksDBCollection::RocksDBCollection(
|
|||
_cache(nullptr),
|
||||
_cachePresent(false),
|
||||
_cacheEnabled(
|
||||
static_cast<RocksDBCollection const*>(physical)->_cacheEnabled) {
|
||||
static_cast<RocksDBCollection const*>(physical)->_cacheEnabled &&
|
||||
CacheManagerFeature::MANAGER != nullptr) {
|
||||
TRI_ASSERT(!ServerState::instance()->isCoordinator());
|
||||
rocksutils::globalRocksEngine()->addCollectionMapping(
|
||||
_objectId, _logicalCollection.vocbase().id(), _logicalCollection.id()
|
||||
|
@ -172,7 +174,8 @@ Result RocksDBCollection::updateProperties(VPackSlice const& slice,
|
|||
auto isSys = _logicalCollection.system();
|
||||
|
||||
_cacheEnabled = !isSys && basics::VelocyPackHelper::readBooleanValue(
|
||||
slice, "cacheEnabled", _cacheEnabled);
|
||||
slice, "cacheEnabled", _cacheEnabled) &&
|
||||
CacheManagerFeature::MANAGER != nullptr;
|
||||
primaryIndex()->setCacheEnabled(_cacheEnabled);
|
||||
|
||||
if (_cacheEnabled) {
|
||||
|
|
|
@ -2056,12 +2056,22 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
|
|||
}
|
||||
|
||||
cache::Manager* manager = CacheManagerFeature::MANAGER;
|
||||
auto rates = manager->globalHitRates();
|
||||
builder.add("cache.limit", VPackValue(manager->globalLimit()));
|
||||
builder.add("cache.allocated", VPackValue(manager->globalAllocation()));
|
||||
// handle NaN
|
||||
builder.add("cache.hit-rate-lifetime", VPackValue(rates.first >= 0.0 ? rates.first : 0.0));
|
||||
builder.add("cache.hit-rate-recent", VPackValue(rates.second >= 0.0 ? rates.second : 0.0));
|
||||
if (manager != nullptr) {
|
||||
// cache turned on
|
||||
auto rates = manager->globalHitRates();
|
||||
builder.add("cache.limit", VPackValue(manager->globalLimit()));
|
||||
builder.add("cache.allocated", VPackValue(manager->globalAllocation()));
|
||||
// handle NaN
|
||||
builder.add("cache.hit-rate-lifetime", VPackValue(rates.first >= 0.0 ? rates.first : 0.0));
|
||||
builder.add("cache.hit-rate-recent", VPackValue(rates.second >= 0.0 ? rates.second : 0.0));
|
||||
} else {
|
||||
// cache turned off
|
||||
builder.add("cache.limit", VPackValue(0));
|
||||
builder.add("cache.allocated", VPackValue(0));
|
||||
// handle NaN
|
||||
builder.add("cache.hit-rate-lifetime", VPackValue(0));
|
||||
builder.add("cache.hit-rate-recent", VPackValue(0));
|
||||
}
|
||||
|
||||
// print column family statistics
|
||||
builder.add("columnFamilies", VPackValue(VPackValueType::Object));
|
||||
|
|
|
@ -64,7 +64,7 @@ RocksDBIndex::RocksDBIndex(
|
|||
_cf(cf),
|
||||
_cache(nullptr),
|
||||
_cachePresent(false),
|
||||
_cacheEnabled(useCache && !collection.system()) {
|
||||
_cacheEnabled(useCache && !collection.system() && CacheManagerFeature::MANAGER != nullptr) {
|
||||
TRI_ASSERT(cf != nullptr && cf != RocksDBColumnFamily::definitions());
|
||||
|
||||
if (_cacheEnabled) {
|
||||
|
@ -90,7 +90,7 @@ RocksDBIndex::RocksDBIndex(
|
|||
_cf(cf),
|
||||
_cache(nullptr),
|
||||
_cachePresent(false),
|
||||
_cacheEnabled(useCache && !collection.system()) {
|
||||
_cacheEnabled(useCache && !collection.system() && CacheManagerFeature::MANAGER != nullptr) {
|
||||
TRI_ASSERT(cf != nullptr && cf != RocksDBColumnFamily::definitions());
|
||||
|
||||
if (_objectId == 0) {
|
||||
|
|
|
@ -121,8 +121,10 @@ Result RocksDBTransactionState::beginTransaction(transaction::Hints hints) {
|
|||
TRI_ASSERT(_cacheTx == nullptr);
|
||||
|
||||
// start cache transaction
|
||||
_cacheTx =
|
||||
CacheManagerFeature::MANAGER->beginTransaction(isReadOnlyTransaction());
|
||||
if (CacheManagerFeature::MANAGER != nullptr) {
|
||||
_cacheTx =
|
||||
CacheManagerFeature::MANAGER->beginTransaction(isReadOnlyTransaction());
|
||||
}
|
||||
|
||||
rocksdb::TransactionDB* db = rocksutils::globalRocksDB();
|
||||
_rocksReadOptions.prefix_same_as_start = true; // should always be true
|
||||
|
@ -232,6 +234,7 @@ void RocksDBTransactionState::cleanupTransaction() noexcept {
|
|||
_rocksTransaction = nullptr;
|
||||
if (_cacheTx != nullptr) {
|
||||
// note: endTransaction() will delete _cacheTrx!
|
||||
TRI_ASSERT(CacheManagerFeature::MANAGER != nullptr);
|
||||
CacheManagerFeature::MANAGER->endTransaction(_cacheTx);
|
||||
_cacheTx = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue