weizuo93 commented on a change in pull request #5737: URL: https://github.com/apache/incubator-doris/pull/5737#discussion_r623563757
########## File path: be/src/http/action/compaction_action.cpp ########## @@ -155,59 +154,66 @@ Status CompactionAction::_handle_run_status_compaction(HttpRequest* req, std::st Status check_status = _check_param(req, &tablet_id, &schema_hash); RETURN_IF_ERROR(check_status); - // fetch the tablet by tablet_id and schema_hash - TabletSharedPtr tablet = - StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id, schema_hash); - if (tablet == nullptr) { - LOG(WARNING) << "invalid argument.tablet_id:" << tablet_id - << ", schema_hash:" << schema_hash; - return Status::InternalError( - strings::Substitute("fail to get $0, $1", tablet_id, schema_hash)); - } - - std::string json_template = R"({ - "status" : "Success", - "run_status" : $0, - "msg" : "$1", - "tablet_id" : $2, - "schema_hash" : $3, - "compact_type" : "$4" + if (tablet_id == 0) { + // overall compaction status + RETURN_IF_ERROR(StorageEngine::instance()->get_compaction_status_json(json_result)); + return Status::OK(); + } else { + // fetch the tablet by tablet_id and schema_hash + TabletSharedPtr tablet = + StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id, schema_hash); + + if (tablet == nullptr) { + LOG(WARNING) << "invalid argument.tablet_id:" << tablet_id + << ", schema_hash:" << schema_hash; + return Status::InternalError( + strings::Substitute("fail to get $0, $1", tablet_id, schema_hash)); + } + + std::string json_template = R"({ + "status" : "Success", + "run_status" : $0, + "msg" : "$1", + "tablet_id" : $2, + "schema_hash" : $3, + "compact_type" : "$4" })"; - - std::string msg = "this tablet_id is not running"; - std::string compaction_type = ""; - bool run_status = 0; - - { - // use try lock to check this tablet is running cumulative compaction - MutexLock lock_cumulative(tablet->get_cumulative_lock(), TRY_LOCK); - if (!lock_cumulative.own_lock()) { - msg = "this tablet_id is running"; - compaction_type = "cumulative"; - run_status = 1; - *json_result = strings::Substitute(json_template, run_status, msg, tablet_id, - schema_hash, compaction_type); - return Status::OK(); + + std::string msg = "this tablet_id is not running"; + std::string compaction_type = ""; + bool run_status = 0; + + { + // use try lock to check this tablet is running cumulative compaction + MutexLock lock_cumulative(tablet->get_cumulative_lock(), TRY_LOCK); + if (!lock_cumulative.own_lock()) { + msg = "this tablet_id is running"; + compaction_type = "cumulative"; + run_status = 1; + *json_result = strings::Substitute(json_template, run_status, msg, tablet_id, + schema_hash, compaction_type); + return Status::OK(); + } } - } - - { - // use try lock to check this tablet is running base compaction - MutexLock lock_base(tablet->get_base_lock(), TRY_LOCK); - if (!lock_base.own_lock()) { - msg = "this tablet_id is running"; - compaction_type = "base"; - run_status = 1; - *json_result = strings::Substitute(json_template, run_status, msg, tablet_id, - schema_hash, compaction_type); - return Status::OK(); + + { + // use try lock to check this tablet is running base compaction + MutexLock lock_base(tablet->get_base_lock(), TRY_LOCK); + if (!lock_base.own_lock()) { + msg = "this tablet_id is running"; Review comment: `this tablet_id is running compaction task`? -- 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. 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