forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry pick to v3.0.0 (0110-0114) (vesoft-inc#3730)
* add LogMonitor to check log disk freeBytes and change log level when space is almost full (vesoft-inc#3576) * add LogMonitor to check the log disk is full * fix comments * add comments for default flags Co-authored-by: yaphet <[email protected]> * Ldbc test cases. (vesoft-inc#3537) * Add ldbc test/ * Add all cases. * Fix some test cases. * Fix ldbc cases. * Fix pytest. Co-authored-by: Yee <[email protected]> * fix issue 3675 (vesoft-inc#3678) * Fix expression rewrite (vesoft-inc#3614) * Do not transfer the filter expression if it contains 2 lableAttribute exprs * Fix expression overflow check * Fix rewriteRelExpr * Refactor rewriteRelExpr * Fix log usage * Check whether the minus expression contains string * Add tck cases * Address comments * Fix conflicts * Address comments * modify metrics in conf files * Address comments * fix divide zone should be failed if two zones use the same host (vesoft-inc#3699) * Support more check about merge zone arguments (vesoft-inc#3703) * fix match index (vesoft-inc#3694) * check scheam * add test case * fix graph crash * address comment' ' * add test case * fix error * fix vid select error * fix unit test error * address comment * fix issue 3601 (vesoft-inc#3666) Co-authored-by: Nivras <[email protected]> Co-authored-by: yaphet <[email protected]> Co-authored-by: cpw <[email protected]> Co-authored-by: Yee <[email protected]> Co-authored-by: Yichen Wang <[email protected]> Co-authored-by: jimingquan <[email protected]> Co-authored-by: hs.zhang <[email protected]>
- Loading branch information
1 parent
a9d4713
commit 2fd67bc
Showing
61 changed files
with
1,927 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2021 vesoft inc. All rights reserved. | ||
# | ||
# This source code is licensed under Apache 2.0 License. | ||
|
||
nebula_add_library( | ||
log_monitor_obj OBJECT | ||
LogMonitor.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
#include "common/log/LogMonitor.h" | ||
|
||
namespace nebula { | ||
|
||
// default min_warn is 256M, disk freebytes < 256M will change LOG_LEVEL to WARNING | ||
DEFINE_uint64(log_min_reserved_bytes_to_warn, | ||
256 * (1UL << 20), | ||
"if freebytes in logdir less than this, will change log level to WARN"); | ||
|
||
// default min_error is 64M, disk freebytes < 64M will change LOG_LEVEL to ERROR | ||
DEFINE_uint64(log_min_reserved_bytes_to_error, | ||
64 * (1UL << 20), | ||
"if freebytes in logdir less than this, will change log level to ERROR"); | ||
|
||
// default min_fatal is 4M, disk freebytes < 4M will change LOG_LEVEL to FATAL | ||
DEFINE_uint64(log_min_reserved_bytes_to_fatal, | ||
4 * (1UL << 20), | ||
"if freebytes in logdir less than this, will change log level to FATAL"); | ||
|
||
// default check log_disk interval is 10s | ||
DEFINE_int32(log_disk_check_interval_secs, 10, "interval to check free space of log path"); | ||
|
||
void LogMonitor::getLogDiskFreeByte() { | ||
boost::system::error_code ec; | ||
auto info = boost::filesystem::space(FLAGS_log_dir, ec); | ||
if (!ec) { | ||
freeByte_ = info.available; | ||
} else { | ||
LOG(WARNING) << "Get filesystem info of logdir: " << FLAGS_log_dir << " failed"; | ||
} | ||
} | ||
|
||
void LogMonitor::checkAndChangeLogLevel() { | ||
getLogDiskFreeByte(); | ||
|
||
if (FLAGS_log_min_reserved_bytes_to_fatal > FLAGS_log_min_reserved_bytes_to_error || | ||
FLAGS_log_min_reserved_bytes_to_fatal > FLAGS_log_min_reserved_bytes_to_warn || | ||
FLAGS_log_min_reserved_bytes_to_error > FLAGS_log_min_reserved_bytes_to_warn) { | ||
LOG(ERROR) << "Get Invalid config in LogMonitor, the LogMonitor config should be " | ||
<< "FLAGS_log_min_reserved_bytes_to_warn >" | ||
<< "FLAGS_log_min_reserved_bytes_to_error > FLAGS_log_min_reserved_bytes_to_fatal;"; | ||
return; | ||
} | ||
|
||
if (freeByte_ < FLAGS_log_min_reserved_bytes_to_fatal) { | ||
LOG(ERROR) << "log disk freebyte is less than " << FLAGS_log_min_reserved_bytes_to_fatal | ||
<< ", change log level to FATAL"; | ||
FLAGS_minloglevel = google::GLOG_FATAL; | ||
} else if (freeByte_ < FLAGS_log_min_reserved_bytes_to_error) { | ||
LOG(ERROR) << "log disk freebyte is less than " << FLAGS_log_min_reserved_bytes_to_error | ||
<< ", change log level to ERROR"; | ||
FLAGS_minloglevel = google::GLOG_ERROR; | ||
} else if (freeByte_ < FLAGS_log_min_reserved_bytes_to_warn) { | ||
LOG(ERROR) << "log disk freebyte is less than " << FLAGS_log_min_reserved_bytes_to_warn | ||
<< ", change log level to WARNING"; | ||
FLAGS_minloglevel = google::GLOG_WARNING; | ||
} else { | ||
// if freeByte_ is bigger than every min_log_flag, reset the FLAGS_minloglevel to old value | ||
if (FLAGS_minloglevel != oldMinLogLevel_) { | ||
FLAGS_minloglevel = oldMinLogLevel_; | ||
} | ||
} | ||
} | ||
|
||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
#pragma once | ||
|
||
#include <boost/filesystem.hpp> | ||
#include <boost/system/error_code.hpp> | ||
|
||
#include "common/thread/GenericWorker.h" | ||
|
||
namespace nebula { | ||
|
||
DECLARE_uint64(log_min_reserved_bytes_to_warn); | ||
DECLARE_uint64(log_min_reserved_bytes_to_error); | ||
DECLARE_uint64(log_min_reserved_bytes_to_fatal); | ||
DECLARE_int32(log_disk_check_interval_secs); | ||
|
||
class LogMonitor { | ||
public: | ||
LogMonitor() : oldMinLogLevel_(FLAGS_minloglevel), freeByte_(1UL << 60) { | ||
worker_ = std::make_shared<thread::GenericWorker>(); | ||
CHECK(worker_->start()); | ||
worker_->addRepeatTask( | ||
FLAGS_log_disk_check_interval_secs * 1000, &LogMonitor::checkAndChangeLogLevel, this); | ||
} | ||
|
||
~LogMonitor() { | ||
worker_->stop(); | ||
worker_->wait(); | ||
} | ||
|
||
void getLogDiskFreeByte(); | ||
|
||
void checkAndChangeLogLevel(); | ||
|
||
private: | ||
int32_t oldMinLogLevel_; | ||
std::shared_ptr<thread::GenericWorker> worker_; | ||
std::atomic_uint64_t freeByte_; | ||
}; | ||
|
||
} // namespace nebula |
Oops, something went wrong.