Skip to content

Commit

Permalink
add balance job type to filter when create backup (#5228)
Browse files Browse the repository at this point in the history
* add more job type to filter when create backup

* log add job

* add log before acquire snapshot lock

Co-authored-by: Sophie <[email protected]>
  • Loading branch information
pengweisong and Sophie-Xie committed Jan 28, 2023
1 parent f41698a commit 2f0ccaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/meta/processors/admin/CreateBackupProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ void CreateBackupProcessor::process(const cpp2::CreateBackupReq& req) {
// make sure there is no index job
std::unordered_set<cpp2::JobType> jobTypes{cpp2::JobType::REBUILD_TAG_INDEX,
cpp2::JobType::REBUILD_EDGE_INDEX,
cpp2::JobType::REBUILD_FULLTEXT_INDEX,
cpp2::JobType::COMPACT,
cpp2::JobType::INGEST,
cpp2::JobType::DATA_BALANCE,
cpp2::JobType::ZONE_BALANCE,
cpp2::JobType::LEADER_BALANCE};
auto result = jobMgr->checkTypeJobRunning(jobTypes);
if (!nebula::ok(result)) {
Expand All @@ -105,6 +107,7 @@ void CreateBackupProcessor::process(const cpp2::CreateBackupReq& req) {
}

folly::SharedMutex::WriteHolder holder(LockUtils::snapshotLock());
LOG(INFO) << "Start to create checkpoints in all hosts.";
// get active storage host list
auto activeHostsRet = ActiveHostsMan::getActiveHosts(kvstore_);
if (!nebula::ok(activeHostsRet)) {
Expand Down
8 changes: 7 additions & 1 deletion src/meta/processors/job/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,13 @@ nebula::cpp2::ErrorCode JobManager::addJob(JobDescription jobDesc) {
if (rc == nebula::cpp2::ErrorCode::SUCCEEDED) {
enqueue(spaceId, jobId, JbOp::ADD, jobDesc.getJobType());
inFlightJobs_.emplace(std::move(jobId), std::move(jobDesc));
LOG(INFO) << folly::sformat("Add job successfully, job id={}, job type={}",
jobId,
apache::thrift::util::enumNameSafe(jobDesc.getJobType()));
} else {
LOG(INFO) << "Add Job Failed";
LOG(INFO) << folly::sformat("Add job failed, job id={}, job type={}",
jobId,
apache::thrift::util::enumNameSafe(jobDesc.getJobType()));
if (rc != nebula::cpp2::ErrorCode::E_LEADER_CHANGED) {
rc = nebula::cpp2::ErrorCode::E_ADD_JOB_FAILURE;
}
Expand Down Expand Up @@ -1002,6 +1007,7 @@ ErrorOr<nebula::cpp2::ErrorCode, bool> JobManager::checkTypeJobRunning(
auto jobDesc = nebula::value(optJobRet);
auto jType = jobDesc.getJobType();
if (jobTypes.find(jType) == jobTypes.end()) {
LOG(INFO) << "skip job type:" << apache::thrift::util::enumNameSafe(jType);
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/test/CreateBackupProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ TEST_F(CreateBackupProcessorTest, Basic) {
TEST_F(CreateBackupProcessorTest, RunningJobs) {
std::vector<cpp2::JobType> jobTypes{cpp2::JobType::REBUILD_TAG_INDEX,
cpp2::JobType::REBUILD_EDGE_INDEX,
cpp2::JobType::REBUILD_FULLTEXT_INDEX,
cpp2::JobType::COMPACT,
cpp2::JobType::INGEST,
cpp2::JobType::DATA_BALANCE,
cpp2::JobType::ZONE_BALANCE,
cpp2::JobType::LEADER_BALANCE};
JobID jobId = 1;
for (auto jobType : jobTypes) {
Expand Down

0 comments on commit 2f0ccaa

Please sign in to comment.