zhannngchen commented on code in PR #22010: URL: https://github.com/apache/doris/pull/22010#discussion_r1295777599
########## be/src/http/action/compaction_action.cpp: ########## @@ -95,44 +110,56 @@ Status CompactionAction::_handle_run_compaction(HttpRequest* req, std::string* j return Status::NotSupported("The compaction type '{}' is not supported", compaction_type); } - // 2. fetch the tablet by tablet_id - TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id); - if (tablet == nullptr) { - return Status::NotFound("Tablet not found. tablet_id={}", tablet_id); - } + if (tablet_id == 0 && table_id != 0) { Review Comment: Should report error if user nether provide tablet id nor table id ########## be/src/http/action/compaction_action.cpp: ########## @@ -95,44 +110,56 @@ Status CompactionAction::_handle_run_compaction(HttpRequest* req, std::string* j return Status::NotSupported("The compaction type '{}' is not supported", compaction_type); } - // 2. fetch the tablet by tablet_id - TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id); - if (tablet == nullptr) { - return Status::NotFound("Tablet not found. tablet_id={}", tablet_id); - } + if (tablet_id == 0 && table_id != 0) { + std::vector<TabletSharedPtr> tablet_vec = + StorageEngine::instance()->tablet_manager()->get_all_tablet( + [table_id](Tablet* tablet) -> bool { + return tablet->get_table_id() == table_id; + }); + for (const auto& tablet : tablet_vec) { + StorageEngine::instance()->submit_compaction_task( + tablet, CompactionType::FULL_COMPACTION, false); + } + } else { + // 2. fetch the tablet by tablet_id + TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id); + if (tablet == nullptr) { + return Status::NotFound("Tablet not found. tablet_id={}", tablet_id); + } - // 3. execute compaction task - std::packaged_task<Status()> task([this, tablet, compaction_type]() { - return _execute_compaction_callback(tablet, compaction_type); - }); - std::future<Status> future_obj = task.get_future(); - std::thread(std::move(task)).detach(); + // 3. execute compaction task + std::packaged_task<Status()> task([this, tablet, compaction_type]() { + return _execute_compaction_callback(tablet, compaction_type); + }); + std::future<Status> future_obj = task.get_future(); + std::thread(std::move(task)).detach(); - // 4. wait for result for 2 seconds by async - std::future_status status = future_obj.wait_for(std::chrono::seconds(2)); - if (status == std::future_status::ready) { - // fetch execute result - Status olap_status = future_obj.get(); - if (!olap_status.ok()) { - return olap_status; + // 4. wait for result for 2 seconds by async + std::future_status status = future_obj.wait_for(std::chrono::seconds(2)); + if (status == std::future_status::ready) { + // fetch execute result + Status olap_status = future_obj.get(); + if (!olap_status.ok()) { + return olap_status; + } + } else { + LOG(INFO) << "Manual compaction task is timeout for waiting " + << (status == std::future_status::timeout); } - } else { - LOG(INFO) << "Manual compaction task is timeout for waiting " - << (status == std::future_status::timeout); } - LOG(INFO) << "Manual compaction task is successfully triggered"; *json_result = - "{\"status\": \"Success\", \"msg\": \"compaction task is successfully triggered.\"}"; - + "{\"status\": \"Success\", \"msg\": \"compaction task is successfully " Review Comment: print table id or tablet id here ########## be/src/http/action/compaction_action.cpp: ########## @@ -95,44 +110,56 @@ Status CompactionAction::_handle_run_compaction(HttpRequest* req, std::string* j return Status::NotSupported("The compaction type '{}' is not supported", compaction_type); } - // 2. fetch the tablet by tablet_id - TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id); - if (tablet == nullptr) { - return Status::NotFound("Tablet not found. tablet_id={}", tablet_id); - } + if (tablet_id == 0 && table_id != 0) { Review Comment: If user provide both of them, should report error as well ########## be/src/olap/tablet.cpp: ########## @@ -1858,14 +1878,29 @@ void Tablet::execute_compaction(CompactionType compaction_type) { return; } set_last_base_compaction_failure_time(0); + } else { + // TODO: full compaction code Review Comment: outdated comment? -- 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