Skip to content

Commit

Permalink
fix bug stop job before it start
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenhui-soul committed Mar 22, 2022
1 parent fd8958b commit 3c985b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/meta/processors/job/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void JobManager::scheduleThread() {
}
usleep(FLAGS_job_check_intervals);
}

std::lock_guard<std::recursive_mutex> lk(muJobFinished_);
auto jobDescRet = JobDescription::loadJobDescription(opJobId.second, kvStore_);
if (!nebula::ok(jobDescRet)) {
LOG(INFO) << "[JobManager] load an invalid job from queue " << opJobId.second;
Expand All @@ -142,7 +142,6 @@ void JobManager::scheduleThread() {
}

bool JobManager::runJobInternal(const JobDescription& jobDesc, JbOp op) {
std::lock_guard<std::recursive_mutex> lk(muJobFinished_);
std::unique_ptr<JobExecutor> je =
JobExecutorFactory::createJobExecutor(jobDesc, kvStore_, adminClient_);
JobExecutor* jobExec = je.get();
Expand Down Expand Up @@ -232,8 +231,9 @@ nebula::cpp2::ErrorCode JobManager::jobFinished(JobID jobId, cpp2::JobStatus job

auto it = runningJobs_.find(jobId);
if (it == runningJobs_.end()) {
LOG(INFO) << folly::sformat("can't find jobExecutor, jobId={}", jobId);
return nebula::cpp2::ErrorCode::E_UNKNOWN;
// the job has not started yet
cleanJob(jobId);
return nebula::cpp2::ErrorCode::SUCCEEDED;
}
std::unique_ptr<JobExecutor>& jobExec = it->second;
if (!optJobDesc.getParas().empty()) {
Expand Down Expand Up @@ -483,11 +483,11 @@ ErrorOr<nebula::cpp2::ErrorCode, std::vector<cpp2::JobDesc>> JobManager::showJob
}

bool JobManager::isExpiredJob(const cpp2::JobDesc& jobDesc) {
auto jobStart = jobDesc.get_start_time();
if (*jobDesc.status_ref() == cpp2::JobStatus::QUEUE ||
*jobDesc.status_ref() == cpp2::JobStatus::RUNNING) {
*jobDesc.status_ref() == cpp2::JobStatus::RUNNING || jobStart == 0) {
return false;
}
auto jobStart = jobDesc.get_start_time();
auto duration = std::difftime(nebula::time::WallClock::fastNowInSec(), jobStart);
return duration > FLAGS_job_expired_secs;
}
Expand Down

0 comments on commit 3c985b1

Please sign in to comment.