This is an automated email from the ASF dual-hosted git repository.
gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 17ac3d9275f [fix](cloud) Guard sync rowset statistics with task
context (#67942)
17ac3d9275f is described below
commit 17ac3d9275f8b7384c976d9bf8a5cc07512602b2
Author: bobhan1 <[email protected]>
AuthorDate: Mon Sep 14 21:46:00 2026 +0800
[fix](cloud) Guard sync rowset statistics with task context (#67942)
### What problem does this PR solve?
Related PR: #61036
When a cloud query is cancelled while tablet synchronization tasks are
still queued, the fragment can destroy its scan local state before a
task starts. The task records its scheduling delay through a raw pointer
into the local state's statistics vector before locking the task
execution context, causing a heap-use-after-free.
Acquire the task context before accessing the statistics and retain it
through the task's deferred cleanup. Keep the execution-start timestamp
at the task entry so the scheduling-delay measurement retains its
original endpoint.
### Release note
Fix a possible BE crash when a cloud query is cancelled during tablet
synchronization.
### Check List (For Author)
- Validation: Clang Format 16.0.6 and `git diff --check` passed; source
review confirmed the context protects statistics access and deferred
cleanup.
- No new tests added. BE compilation, ASAN tests, and regression tests
were not run.
- Behavior changed: Yes, tasks whose execution context has expired
return before accessing scan statistics.
- Documentation needed: No.
---
be/src/exec/operator/olap_scan_operator.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/be/src/exec/operator/olap_scan_operator.cpp
b/be/src/exec/operator/olap_scan_operator.cpp
index d8fcac7579f..4667eee86f6 100644
--- a/be/src/exec/operator/olap_scan_operator.cpp
+++ b/be/src/exec/operator/olap_scan_operator.cpp
@@ -878,16 +878,17 @@ Status
OlapScanLocalState::_sync_cloud_tablets(RuntimeState* state) {
tasks.emplace_back([this, sync_stats, version, i, task_ctx,
task_create_time]() {
// Record bthread scheduling delay
auto task_start_time = std::chrono::steady_clock::now();
+ auto task_lock = task_ctx.lock();
+ if (task_lock == nullptr) {
+ return Status::OK();
+ }
+ // The local state owns sync_stats, so keep its context
alive before access.
if (sync_stats) {
sync_stats->bthread_schedule_delay_ns +=
std::chrono::duration_cast<std::chrono::nanoseconds>(
task_start_time - task_create_time)
.count();
}
- auto task_lock = task_ctx.lock();
- if (task_lock == nullptr) {
- return Status::OK();
- }
Defer defer([&] {
if (_pending_tablets_num.fetch_sub(1) == 1) {
_cloud_tablet_dependency->set_ready();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]