Skip to content

Commit

Permalink
[feat]curvefs: change some conf on fly
Browse files Browse the repository at this point in the history
1. use gflag to change mds heartbeatMissTimeOutMs on fly
2. use gflag to change metaserver transh.expiredAfterSec on fly
3. use gflag to change metaserver transh.scanPeriodSec on fly

Signed-off-by: Cyber-SiKu <[email protected]>
  • Loading branch information
Cyber-SiKu committed Oct 18, 2023
1 parent 5df3d6b commit 4b4d1fa
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion curvefs/conf/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ s3.logLevel=4
s3.logPrefix=/data/logs/curvefs/aws_ # __CURVEADM_TEMPLATE__ /curvefs/client/logs/aws_ __CURVEADM_TEMPLATE__
s3.asyncThreadNum=500
# limit all inflight async requests' bytes, |0| means not limited
s3.maxAsyncRequestInflightBytes=104857600
s3.maxAsyncRequestInflightBytes=1073741824
s3.chunkFlushThreads=5
# throttle
s3.throttle.iopsTotalLimit=0
Expand Down
21 changes: 20 additions & 1 deletion curvefs/src/mds/heartbeat/metaserver_healthy_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ using ::curvefs::mds::topology::TopoStatusCode;
using ::curve::common::WriteLockGuard;
using std::chrono::milliseconds;

// the maximun peroid that heartbeat is missed without
// setting the metaserver to offline status and alarm.
// scheduling will depend on this status of metaserver
DEFINE_uint64(heartbeat_OffLineTimeOutMs, 1800000,
"the maximun peroid that heartbeat is missed without setting the "
"metaserver to offline status and alarm.");

// network jitter is unavoidable, and for this reason
// background process will alarm during the inspection once it
// finds out that heartbeat is missed after heartbeatMissTimeOut peroid
DEFINE_uint64(
heartbeat_MissTimeOutMs, 30000,
"background process will alarm during the inspection once it finds out "
"that heartbeat is missed after heartbeatMissTimeOut peroid");
DEFINE_validator(heartbeat_OffLineTimeOutMs, [](const char*, uint64_t value) {
return value >= FLAGS_heartbeat_MissTimeOutMs;
});

namespace curvefs {
namespace mds {
namespace heartbeat {
Expand Down Expand Up @@ -68,7 +86,8 @@ bool MetaserverHealthyChecker::MetaServerStateNeedUpdate(
return false;
}

bool shouldUnstable = (timePass < milliseconds(option_.offLineTimeOutMs));
bool shouldUnstable =
(timePass < milliseconds(FLAGS_heartbeat_OffLineTimeOutMs));
if (shouldUnstable) {
if (OnlineState::UNSTABLE != info.state) {
LOG(WARNING) << "metaserver " << info.msId << " is unstable. "
Expand Down
36 changes: 27 additions & 9 deletions curvefs/src/mds/heartbeat/metaserver_healthy_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,25 @@
#ifndef CURVEFS_SRC_MDS_HEARTBEAT_METASERVER_HEALTHY_CHECKER_H_
#define CURVEFS_SRC_MDS_HEARTBEAT_METASERVER_HEALTHY_CHECKER_H_

#include <chrono> //NOLINT
#include <memory>
#include <gflags/gflags_declare.h>

#include <chrono> //NOLINT
#include <map>
#include "curvefs/src/mds/common/types.h"
#include <memory>

#include "curvefs/proto/topology.pb.h"
#include "curvefs/src/mds/common/mds_define.h"
#include "curvefs/src/mds/common/types.h"
#include "curvefs/src/mds/topology/topology.h"
#include "curvefs/proto/topology.pb.h"

using ::std::chrono::steady_clock;
using ::curvefs::mds::topology::MetaServerIdType;
using ::curvefs::mds::topology::Topology;
using ::curvefs::mds::topology::OnlineState;

DECLARE_uint64(heartbeat_OffLineTimeOutMs);
DECLARE_uint64(heartbeat_MissTimeOutMs);

namespace curvefs {
namespace mds {
namespace heartbeat {
Expand All @@ -45,8 +51,20 @@ struct HeartbeatOption {
uint64_t heartbeatMissTimeout,
uint64_t offLineTimeout) {
this->heartbeatIntervalMs = heartbeatInterval;
this->heartbeatMissTimeOutMs = heartbeatMissTimeout;
this->offLineTimeOutMs = offLineTimeout;
FLAGS_heartbeat_MissTimeOutMs = this->heartbeatMissTimeOutMs =
heartbeatMissTimeout;
FLAGS_heartbeat_OffLineTimeOutMs = this->offLineTimeOutMs =
offLineTimeout;
}

explicit HeartbeatOption(const HeartbeatOption& option)
: heartbeatIntervalMs(option.heartbeatIntervalMs),
heartbeatMissTimeOutMs(option.heartbeatMissTimeOutMs),
offLineTimeOutMs(option.offLineTimeOutMs),
cleanFollowerAfterMs(option.cleanFollowerAfterMs),
mdsStartTime(option.mdsStartTime) {
FLAGS_heartbeat_OffLineTimeOutMs = offLineTimeOutMs;
FLAGS_heartbeat_MissTimeOutMs = heartbeatMissTimeOutMs;
}

// heartbeatIntervalMs: normal heartbeat interval.
Expand Down Expand Up @@ -90,9 +108,9 @@ struct HeartbeatInfo {

class MetaserverHealthyChecker {
public:
MetaserverHealthyChecker(
HeartbeatOption option, const std::shared_ptr<Topology> &topo) :
option_(option), topo_(topo) {}
MetaserverHealthyChecker(const HeartbeatOption& option,
const std::shared_ptr<Topology>& topo)
: option_(option), topo_(topo) {}
~MetaserverHealthyChecker() {}

/**
Expand Down
15 changes: 13 additions & 2 deletions curvefs/src/metaserver/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
*/

#include "curvefs/src/metaserver/trash.h"
#include "src/common/timeutility.h"

#include "curvefs/proto/mds.pb.h"
#include "curvefs/src/metaserver/inode_storage.h"
#include "src/common/timeutility.h"

using ::curve::common::TimeUtility;

Expand All @@ -32,9 +34,18 @@ namespace metaserver {
using ::curvefs::mds::FsInfo;
using ::curvefs::mds::FSStatusCode;

bool pass_uint32(const char*, uint32_t value) { return true; }
DEFINE_uint32(trash_expiredAfterSec, 604800,
"time to delete data in the recycle bin");
DEFINE_uint32(trash_scanPeriodSec, 600, "recycle bin scan interval");
DEFINE_validator(trash_expiredAfterSec, pass_uint32);
DEFINE_validator(trash_scanPeriodSec, pass_uint32);

void TrashOption::InitTrashOptionFromConf(std::shared_ptr<Configuration> conf) {
conf->GetValueFatalIfFail("trash.scanPeriodSec", &scanPeriodSec);
FLAGS_trash_scanPeriodSec = scanPeriodSec;
conf->GetValueFatalIfFail("trash.expiredAfterSec", &expiredAfterSec);
FLAGS_trash_expiredAfterSec = expiredAfterSec;
}

void TrashImpl::Init(const TrashOption &option) {
Expand Down Expand Up @@ -129,7 +140,7 @@ bool TrashImpl::NeedDelete(const TrashItem &item) {
// if fs recycleTimeHour is not 0, return true
uint64_t recycleTimeHour = GetFsRecycleTimeHour(item.fsId);
if (recycleTimeHour == 0) {
return ((now - item.dtime) >= options_.expiredAfterSec);
return ((now - item.dtime) >= FLAGS_trash_expiredAfterSec);
} else {
return true;
}
Expand Down
8 changes: 5 additions & 3 deletions curvefs/src/metaserver/trash_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
namespace curvefs {
namespace metaserver {

DECLARE_uint32(trash_scanPeriodSec);

int TrashManager::Run() {
if (isStop_.exchange(false)) {
recycleThread_ =
Expand All @@ -48,9 +50,9 @@ void TrashManager::Fini() {
}

void TrashManager::ScanLoop() {
while (sleeper_.wait_for(std::chrono::seconds(options_.scanPeriodSec))) {
ScanEveryTrash();
}
while (sleeper_.wait_for(std::chrono::seconds(FLAGS_trash_scanPeriodSec))) {
ScanEveryTrash();
}
}

void TrashManager::ScanEveryTrash() {
Expand Down

0 comments on commit 4b4d1fa

Please sign in to comment.