github-actions[bot] commented on code in PR #61222:
URL: https://github.com/apache/doris/pull/61222#discussion_r3090684397
##########
be/src/service/http/action/compaction_action.cpp:
##########
@@ -178,33 +186,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
Review Comment:
This changes the single-tablet `full` path from "spawn a detached worker and
return after `wait_for(2s)`" to a synchronous `submit_compaction_task()` call.
On the local engine that helper immediately runs
`Tablet::prepare_compaction_and_calculate_permits()`, and
`FullCompaction::prepare_compact()` takes the base/cumulative compaction locks
with blocking `std::unique_lock`s. If a base or cumulative compaction is
already running on this tablet, the POST handler now waits for that compaction
to finish before replying, which is a user-visible regression for
`/api/compaction/run` and can tie up an HTTP worker for minutes. Can we keep
full-compaction `prepare_compact()` off the request thread (or fail fast when
those locks are busy) so the API stays asynchronous like before?
##########
be/src/service/http/action/compaction_action.cpp:
##########
@@ -178,33 +186,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,
Review Comment:
This new call site now inherits a latent bug in
`StorageEngine::_submit_compaction_task()`: after `auto status =
thread_pool->submit_func(...)`, the code still checks `if (!st.ok())`, where
`st` is the earlier prepare status and is already `OK`. So if enqueueing fails
(for example because the pool is shutting down, or no worker thread can be
created), the error is dropped and this request still returns success while
leaving the registry / permit / task-tracker state behind. Single-tablet `full`
compaction did not depend on that helper before this PR, so this becomes
user-visible here. Please fix the submit-status check before routing this path
through the thread pool.
--
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]