Copilot commented on code in PR #60285:
URL: https://github.com/apache/doris/pull/60285#discussion_r2732416065
##########
be/src/runtime/load_stream.cpp:
##########
@@ -293,21 +289,36 @@ Status
TabletStream::_run_in_heavy_work_pool(std::function<Status()> fn) {
return st;
}
-void TabletStream::pre_close() {
+void TabletStream::wait_for_flush_tasks() {
+ {
+ std::lock_guard lock_guard(_lock);
+ if (_flush_tasks_done) {
+ return;
+ }
+ _flush_tasks_done = true;
+ }
+
if (!_status.ok()) {
- // cancel all pending tasks, wait all running tasks to finish
_flush_token->shutdown();
return;
}
- SCOPED_TIMER(_close_wait_timer);
- _status.update(_run_in_heavy_work_pool([this]() {
+ // Use heavy_work_pool to avoid blocking bthread
+ auto st = _run_in_heavy_work_pool([this]() {
_flush_token->wait();
return Status::OK();
- }));
- // it is necessary to check status after wait_func,
- // for create_rowset could fail during add_segment when loading to MOW
table,
- // in this case, should skip close to avoid submit_calc_delete_bitmap_task
which could cause coredump.
+ });
+ if (!st.ok()) {
+ // If heavy_work_pool is unavailable, fall back to shutdown
+ // which will cancel pending tasks and wait for running tasks
+ _flush_token->shutdown();
+ _status.update(st);
+ }
+}
Review Comment:
The timing measurement for waiting on flush tasks has been removed. In the
original implementation, `pre_close()` wrapped the flush token wait operation
with `SCOPED_TIMER(_close_wait_timer)`. Now that this logic has been extracted
to `wait_for_flush_tasks()`, which can be called from both `pre_close()` and
the destructor, the timing is no longer tracked when called from `pre_close()`.
If profiling is important for the normal close flow, consider adding
conditional timing instrumentation, or accepting that timing is lost when this
is refactored into a reusable method that's also called from the destructor.
--
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]