mirror of https://gitee.com/bigwinds/arangodb
back port PR 9874 to 3.5. Add write amplification stat and option to disable statistics history. (#9947)
This commit is contained in:
parent
4f857055e8
commit
249899959f
|
@ -1,6 +1,11 @@
|
|||
v3.5.1 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* Add --server.statistics-history flag to allow disabling of only the historical
|
||||
statistics. Also added rocksdbengine.write.amplification.x100 statistics
|
||||
for measurement of compaction option impact. Enabled non-historical
|
||||
statistics for agents.
|
||||
|
||||
* Fixed AQL constrained-heap sort in conjunction with fullCount.
|
||||
|
||||
* Added support for AQL expressions such as `a NOT LIKE b`, `a NOT =~ b` and
|
||||
|
|
|
@ -234,12 +234,11 @@ void AgencyFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
|||
// - ArangoSearch: not needed by agency even if MMFiles is the selected
|
||||
// storage engine
|
||||
// - IResearchAnalyzer: analyzers are not needed by agency
|
||||
// - Statistics: turn off statistics gathering for agency
|
||||
// - Action/Script/FoxxQueues/Frontend: Foxx and JavaScript APIs
|
||||
|
||||
std::vector<std::string> disabledFeatures({
|
||||
"MMFilesPersistentIndex", "ArangoSearch", "ArangoSearchAnalyzer",
|
||||
"Statistics", "Action", "Script", "FoxxQueues", "Frontend"});
|
||||
"Action", "Script", "FoxxQueues", "Frontend"});
|
||||
|
||||
if (!result.touched("console") || !*(options->get<BooleanParameter>("console")->ptr)) {
|
||||
// specifiying --console requires JavaScript, so we can only turn it off
|
||||
|
|
|
@ -107,7 +107,7 @@ using namespace arangodb::application_features;
|
|||
using namespace arangodb::options;
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
|
||||
std::string const RocksDBEngine::EngineName("rocksdb");
|
||||
std::string const RocksDBEngine::FeatureName("RocksDBEngine");
|
||||
|
||||
|
@ -309,7 +309,7 @@ void RocksDBEngine::collectOptions(std::shared_ptr<options::ProgramOptions> opti
|
|||
"true to enable rocksdb debug logging",
|
||||
new BooleanParameter(&_debugLogging),
|
||||
arangodb::options::makeFlags(arangodb::options::Flags::Hidden));
|
||||
|
||||
|
||||
options->addOption("--rocksdb.wal-archive-size-limit",
|
||||
"maximum total size (in bytes) of archived WAL files (0 = unlimited)",
|
||||
new UInt64Parameter(&_maxWalArchiveSizeLimit),
|
||||
|
@ -371,12 +371,12 @@ void RocksDBEngine::prepare() {
|
|||
void RocksDBEngine::start() {
|
||||
// it is already decided that rocksdb is used
|
||||
TRI_ASSERT(isEnabled());
|
||||
|
||||
|
||||
if (ServerState::instance()->isAgent() &&
|
||||
!application_features::ApplicationServer::server->options()->processingResult().touched("rocksdb.wal-file-timeout-initial")) {
|
||||
// reduce --rocksb.wal-file-timeout-initial to 15 seconds for agency nodes
|
||||
// as we probably won't need the WAL for WAL tailing and replication here
|
||||
_pruneWaitTimeInitial = 15;
|
||||
_pruneWaitTimeInitial = 15;
|
||||
}
|
||||
|
||||
LOG_TOPIC("107fd", TRACE, arangodb::Logger::ENGINES)
|
||||
|
@ -625,7 +625,7 @@ void RocksDBEngine::start() {
|
|||
cfFamilies.emplace_back("VPackIndex", vpackFixedPrefCF); // 4
|
||||
cfFamilies.emplace_back("GeoIndex", fixedPrefCF); // 5
|
||||
cfFamilies.emplace_back("FulltextIndex", fixedPrefCF); // 6
|
||||
|
||||
|
||||
TRI_ASSERT(static_cast<int>(_options.max_write_buffer_number) >= static_cast<int>(cfFamilies.size()));
|
||||
// Update max_write_buffer_number above if you change number of families used
|
||||
|
||||
|
@ -750,7 +750,7 @@ void RocksDBEngine::start() {
|
|||
if (opts->_limitOpenFilesAtStartup) {
|
||||
_db->SetDBOptions({{"max_open_files", "-1"}});
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
auto feature = application_features::ApplicationServer::getFeature<FlushFeature>("Flush");
|
||||
TRI_ASSERT(feature);
|
||||
|
@ -804,7 +804,7 @@ void RocksDBEngine::beginShutdown() {
|
|||
|
||||
void RocksDBEngine::stop() {
|
||||
TRI_ASSERT(isEnabled());
|
||||
|
||||
|
||||
// in case we missed the beginShutdown somehow, call it again
|
||||
replicationManager()->beginShutdown();
|
||||
replicationManager()->dropAll();
|
||||
|
@ -1751,7 +1751,7 @@ void RocksDBEngine::determinePrunableWalFiles(TRI_voc_tick_t minTickExternal) {
|
|||
// we need to take its start tick into account as well, because the following
|
||||
// file's start tick can be assumed to be the end tick of the current file!
|
||||
if (f->StartSequence() < minTickToKeep &&
|
||||
current < files.size() - 1) {
|
||||
current < files.size() - 1) {
|
||||
auto const& n = files[current + 1].get();
|
||||
if (n->StartSequence() < minTickToKeep) {
|
||||
// this file will be removed because it does not contain any data we
|
||||
|
@ -1765,7 +1765,7 @@ void RocksDBEngine::determinePrunableWalFiles(TRI_voc_tick_t minTickExternal) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_maxWalArchiveSizeLimit == 0) {
|
||||
// size of the archive is not restricted. done!
|
||||
return;
|
||||
|
@ -1773,7 +1773,7 @@ void RocksDBEngine::determinePrunableWalFiles(TRI_voc_tick_t minTickExternal) {
|
|||
|
||||
// print current archive size
|
||||
LOG_TOPIC("8d71b", TRACE, Logger::ENGINES) << "total size of the RocksDB WAL file archive: " << totalArchiveSize;
|
||||
|
||||
|
||||
if (totalArchiveSize <= _maxWalArchiveSizeLimit) {
|
||||
// archive is smaller than allowed. all good
|
||||
return;
|
||||
|
@ -2042,7 +2042,7 @@ void RocksDBEngine::addSystemDatabase() {
|
|||
std::unique_ptr<TRI_vocbase_t> RocksDBEngine::openExistingDatabase(
|
||||
TRI_voc_tick_t id, std::string const& name, bool wasCleanShutdown, bool isUpgrade, bool isVersionCheck) {
|
||||
auto vocbase = std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id, name);
|
||||
|
||||
|
||||
// scan the database path for views
|
||||
if (!isVersionCheck) {
|
||||
try {
|
||||
|
@ -2235,6 +2235,14 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
|
|||
for (auto const& stat : rocksdb::TickersNameMap) {
|
||||
builder.add(stat.second, VPackValue(_options.statistics->getTickerCount(stat.first)));
|
||||
}
|
||||
|
||||
uint64_t walWrite, flushWrite, compactionWrite, userWrite;
|
||||
walWrite = _options.statistics->getTickerCount(rocksdb::WAL_FILE_BYTES);
|
||||
flushWrite = _options.statistics->getTickerCount(rocksdb::FLUSH_WRITE_BYTES);
|
||||
compactionWrite = _options.statistics->getTickerCount(rocksdb::COMPACT_WRITE_BYTES);
|
||||
userWrite = _options.statistics->getTickerCount(rocksdb::BYTES_WRITTEN);
|
||||
builder.add("rocksdbengine.write.amplification.x100",
|
||||
VPackValue( (0 != userWrite) ? ((walWrite+flushWrite+compactionWrite)*100)/userWrite : 100));
|
||||
}
|
||||
|
||||
cache::Manager* manager = CacheManagerFeature::MANAGER;
|
||||
|
@ -2304,7 +2312,7 @@ Result RocksDBEngine::createLoggerState(TRI_vocbase_t* vocbase, VPackBuilder& bu
|
|||
|
||||
// "clients" part
|
||||
builder.add("clients", VPackValue(VPackValueType::Array)); // open
|
||||
if (vocbase != nullptr) {
|
||||
if (vocbase != nullptr) {
|
||||
vocbase->replicationClients().toVelocyPack(builder);
|
||||
}
|
||||
builder.close(); // clients
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "StatisticsFeature.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "ProgramOptions/ProgramOptions.h"
|
||||
#include "ProgramOptions/Section.h"
|
||||
|
@ -127,6 +128,8 @@ StatisticsFeature* StatisticsFeature::STATISTICS = nullptr;
|
|||
StatisticsFeature::StatisticsFeature(application_features::ApplicationServer& server)
|
||||
: ApplicationFeature(server, "Statistics"),
|
||||
_statistics(true),
|
||||
_statisticsHistory(true),
|
||||
_statisticsHistoryTouched(false),
|
||||
_descriptions(new stats::Descriptions()) {
|
||||
startsAfter("AQLPhase");
|
||||
setOptional(true);
|
||||
|
@ -141,13 +144,22 @@ void StatisticsFeature::collectOptions(std::shared_ptr<ProgramOptions> options)
|
|||
"turn statistics gathering on or off",
|
||||
new BooleanParameter(&_statistics),
|
||||
arangodb::options::makeFlags(arangodb::options::Flags::Hidden));
|
||||
options->addOption("--server.statistics-history",
|
||||
"turn storing statistics in database on or off",
|
||||
new BooleanParameter(&_statisticsHistory),
|
||||
arangodb::options::makeFlags(arangodb::options::Flags::Hidden))
|
||||
.setIntroducedIn(30409)
|
||||
.setIntroducedIn(30501);
|
||||
}
|
||||
|
||||
void StatisticsFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||
void StatisticsFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
||||
if (!_statistics) {
|
||||
// turn ourselves off
|
||||
disable();
|
||||
}
|
||||
|
||||
_statisticsHistoryTouched = options->processingResult().touched("--server.statistics-history");
|
||||
|
||||
}
|
||||
|
||||
void StatisticsFeature::prepare() {
|
||||
|
@ -181,7 +193,6 @@ void StatisticsFeature::start() {
|
|||
}
|
||||
|
||||
_statisticsThread.reset(new StatisticsThread);
|
||||
_statisticsWorker.reset(new StatisticsWorker(*vocbase));
|
||||
|
||||
if (!_statisticsThread->start()) {
|
||||
LOG_TOPIC("46b0c", FATAL, arangodb::Logger::STATISTICS)
|
||||
|
@ -189,11 +200,20 @@ void StatisticsFeature::start() {
|
|||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
|
||||
if (!_statisticsWorker->start()) {
|
||||
LOG_TOPIC("6ecdc", FATAL, arangodb::Logger::STATISTICS)
|
||||
// force history disable on Agents
|
||||
if (arangodb::ServerState::instance()->isAgent() && !_statisticsHistoryTouched) {
|
||||
_statisticsHistory = false;
|
||||
} // if
|
||||
|
||||
if (_statisticsHistory) {
|
||||
_statisticsWorker.reset(new StatisticsWorker(*vocbase));
|
||||
|
||||
if (!_statisticsWorker->start()) {
|
||||
LOG_TOPIC("6ecdc", FATAL, arangodb::Logger::STATISTICS)
|
||||
<< "could not start statistics worker";
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
} // if
|
||||
}
|
||||
|
||||
void StatisticsFeature::stop() {
|
||||
|
|
|
@ -93,6 +93,8 @@ class StatisticsFeature final : public application_features::ApplicationFeature
|
|||
|
||||
private:
|
||||
bool _statistics;
|
||||
bool _statisticsHistory;
|
||||
bool _statisticsHistoryTouched;
|
||||
|
||||
std::unique_ptr<stats::Descriptions> _descriptions;
|
||||
std::unique_ptr<StatisticsThread> _statisticsThread;
|
||||
|
|
Loading…
Reference in New Issue