weizuo93 commented on a change in pull request #7521: URL: https://github.com/apache/incubator-doris/pull/7521#discussion_r785864111
########## File path: be/src/agent/task_worker_pool.cpp ########## @@ -1650,4 +1654,73 @@ void TaskWorkerPool::_random_sleep(int second) { sleep(rnd.Uniform(second) + 1); } +void TaskWorkerPool::_submit_table_compaction_worker_thread_callback() { + while (_is_work) { + TAgentTaskRequest agent_task_req; + TCompactionReq compaction_req; + + { + lock_guard<Mutex> worker_thread_lock(_worker_thread_lock); + while (_is_work && _tasks.empty()) { + _worker_thread_condition_variable.wait(); + } + if (!_is_work) { + return; + } + + agent_task_req = _tasks.front(); + compaction_req = agent_task_req.compaction_req; + _tasks.pop_front(); + } + + LOG(INFO) << "get compaction task. signature:" << agent_task_req.signature + << ", compaction type:" << compaction_req.type; + + CompactionType compaction_type; + if (compaction_req.type == "base") { + compaction_type = CompactionType::BASE_COMPACTION; + } else { + compaction_type = CompactionType::CUMULATIVE_COMPACTION; + } + + TabletSharedPtr tablet_ptr = StorageEngine::instance()->tablet_manager()->get_tablet( + compaction_req.tablet_id, compaction_req.schema_hash); + if (tablet_ptr != nullptr) { + auto data_dir = tablet_ptr->data_dir(); + if (!tablet_ptr->can_do_compaction(data_dir->path_hash(), compaction_type)) { + LOG(WARNING) << "can not do compaction: " << tablet_ptr->tablet_id() + << ", compaction type: " << compaction_type; + _remove_task_info(agent_task_req.task_type, agent_task_req.signature); + continue; + } + + if (compaction_type == CompactionType::BASE_COMPACTION) { Review comment: > Is it necessary to check lock here? OK. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org