Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cacct priority val error #414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions protos/PublicDefs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ message TaskToCtld {

bool requeue_if_failed = 12;
bool get_user_env = 13;
uint32 priority = 14;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提交的时候哪来的优先级

Copy link
Collaborator Author

@1daidai1 1daidai1 Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加这个的目的是考虑突然掉电情况下恢复任务running任务恢复以及completed任务没有存在mongodb中,从嵌入式db数据库恢复过来优先级变成零的情况,没有保存最后一次的优先级,那么最后存在mongodb会出现优先级不是真实优先级的情况


oneof payload {
BatchTaskAdditionalMeta batch_meta = 21;
Expand Down
6 changes: 4 additions & 2 deletions src/CraneCtld/DbClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ bool MongodbClient::FetchJobRecords(
task->set_type((crane::grpc::TaskType)view["type"].get_int32().value);

task->set_extra_attr(view["extra_attr"].get_string().value.data());

task->set_priority(view["priority"].get_int64().value);
}
} catch (const bsoncxx::exception& e) {
PrintError_(e.what());
Expand Down Expand Up @@ -869,7 +871,7 @@ MongodbClient::document MongodbClient::TaskInEmbeddedDbToDocument_(
util::HostNameListToStr(runtime_attr.craned_ids()),
runtime_attr.craned_ids().size(), 0, task_to_ctld.partition_name(),
// 15-19
0, 0, runtime_attr.start_time().seconds(),
task_to_ctld.priority(), 0, runtime_attr.start_time().seconds(),
runtime_attr.end_time().seconds(), 0,
// 20-24
task_to_ctld.batch_meta().sh_script(), runtime_attr.status(),
Expand Down Expand Up @@ -942,7 +944,7 @@ MongodbClient::document MongodbClient::TaskInCtldToDocument_(TaskInCtld* task) {
static_cast<int32_t>(task->Gid()), task->allocated_craneds_regex,
static_cast<int32_t>(task->nodes_alloc), 0, task->partition_id,
// 15-19
0, 0, task->StartTimeInUnixSecond(), task->EndTimeInUnixSecond(),
static_cast<int64_t>(task->cached_priority), 0, task->StartTimeInUnixSecond(), task->EndTimeInUnixSecond(),
0,
// 20-24
script, task->Status(), absl::ToInt64Seconds(task->time_limit),
Expand Down
3 changes: 3 additions & 0 deletions src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2904,6 +2904,9 @@ std::vector<task_id_t> MultiFactorPriority::GetOrderedTaskIdList(
task->cached_priority = priority;
task->pending_reason = "Priority";
task_priority_vec.emplace_back(task.get(), priority);
task->MutableTaskToCtld()->set_priority(priority);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调度里面的代码都删了

g_embedded_db_client->UpdateTaskToCtldIfExists(0, task->TaskDbId(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行代码不该加 删了

task->TaskToCtld());
}

std::sort(task_priority_vec.begin(), task_priority_vec.end(),
Expand Down