github-actions[bot] commented on code in PR #61222:
URL: https://github.com/apache/doris/pull/61222#discussion_r3031337906
##########
be/src/service/http/action/compaction_action.cpp:
##########
@@ -177,33 +185,36 @@ Status
CompactionAction::_handle_run_compaction(HttpRequest* req, std::string* j
return Status::OK();
})
- // 3. execute compaction task
- std::packaged_task<Status()> task([this, tablet, compaction_type,
fetch_from_remote]() {
- return _execute_compaction_callback(tablet, compaction_type,
fetch_from_remote);
- });
- std::future<Status> future_obj = task.get_future();
- std::thread(std::move(task)).detach();
-
- // 更新schedule_time
- if (compaction_type == PARAM_COMPACTION_BASE) {
- tablet->set_last_base_compaction_schedule_time(UnixMillis());
- } else if (compaction_type == PARAM_COMPACTION_CUMULATIVE) {
- tablet->set_last_cumu_compaction_schedule_time(UnixMillis());
- } else if (compaction_type == PARAM_COMPACTION_FULL) {
+ if (compaction_type == PARAM_COMPACTION_FULL) {
+ // 3. submit full compaction task to thread pool
tablet->set_last_full_compaction_schedule_time(UnixMillis());
- }
+ RETURN_IF_ERROR(
+ _engine.submit_compaction_task(tablet,
CompactionType::FULL_COMPACTION, force));
+ } else {
+ // 3. execute base/cumulative compaction task in a detached thread
+ std::packaged_task<Status()> task([this, tablet, compaction_type,
fetch_from_remote]() {
+ return _execute_compaction_callback(tablet, compaction_type,
fetch_from_remote);
+ });
+ std::future<Status> future_obj = task.get_future();
Review Comment:
Switching single-tablet `full` compaction to `submit_compaction_task()` adds
a queued state here, but `_handle_run_status_compaction()` still treats `full`
as running only when `tablet->is_full_compaction_running()` is true. That means
a request can return success from this line, sit in the base-compaction pool,
and still report `run_status = false` to any caller polling
`/api/compaction/run_status`. The new Groovy workaround masks that for one
helper, but the HTTP API itself is now inconsistent. Can we expose
pending/submitted full compactions in `run_status` before moving this path onto
the queue?
##########
regression-test/plugins/plugin_compaction.groovy:
##########
@@ -137,8 +137,10 @@ Suite.metaClass.trigger_and_wait_compaction = { String
table_name, String compac
assert exit_code == 0: "get tablet status failed, exit code:
${exit_code}, stdout: ${stdout}, stderr: ${stderr}"
def tabletStatus = parseJson(stdout.trim())
def oldStatus =
be_tablet_compaction_status.get("${be_host}-${tablet.TabletId}")
- // last compaction success time isn't updated, indicates
compaction is not started(so we treat it as running and wait)
- running = running || (oldStatus["last ${compaction_type}
success time"] == tabletStatus["last ${compaction_type} success time"])
+ // last compaction success/failure time isn't updated,
indicates compaction is not started(so we treat it as running and wait)
+ def success_time_unchanged = (oldStatus["last
${compaction_type} success time"] == tabletStatus["last ${compaction_type}
success time"])
+ def failure_time_unchanged = (oldStatus["last
${compaction_type} failure time"] == tabletStatus["last ${compaction_type}
failure time"])
+ running = running || (success_time_unchanged &&
failure_time_unchanged)
Review Comment:
This condition is too broad for `base`/`cumulative`. Those paths can change
`last ... failure time` without ever completing the requested compaction. For
example, cumulative tasks can be delayed/aborted in
`StorageEngine::_handle_compaction()` after updating
`last_cumu_compaction_failure_time`, with `run_status` already false. In that
case `failure_time_unchanged` becomes false and this helper stops waiting even
though no compaction actually ran. The timestamp workaround seems safe only for
queued `full` compaction; for the other modes we still need the old behavior or
an explicit pending-state signal from BE.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]