This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 179d4ab754e [bugfix](potential bug) add lock when modify total tasks
number (#27428)
179d4ab754e is described below
commit 179d4ab754ed51edbbdc200f9ec7b0bc4a44ef67
Author: yiguolei <[email protected]>
AuthorDate: Thu Nov 23 09:28:09 2023 +0800
[bugfix](potential bug) add lock when modify total tasks number (#27428)
Co-authored-by: yiguolei <[email protected]>
---
be/src/pipeline/pipeline_fragment_context.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/be/src/pipeline/pipeline_fragment_context.cpp
b/be/src/pipeline/pipeline_fragment_context.cpp
index 7ccfe251a02..d4c2fd2b694 100644
--- a/be/src/pipeline/pipeline_fragment_context.cpp
+++ b/be/src/pipeline/pipeline_fragment_context.cpp
@@ -703,9 +703,18 @@ Status PipelineFragmentContext::submit() {
for (auto& task : _tasks) {
st = scheduler->schedule_task(task.get());
if (!st) {
- std::lock_guard<std::mutex> l(_status_lock);
- cancel(PPlanFragmentCancelReason::INTERNAL_ERROR, "submit context
fail");
- _total_tasks = submit_tasks;
+ {
+ std::lock_guard<std::mutex> l(_status_lock);
+ cancel(PPlanFragmentCancelReason::INTERNAL_ERROR, "submit
context fail");
+ }
+ {
+ // The fragment instance may contains 10 tasks, maybe 8 of
them is in scheduler running
+ // and the 9th failed to add to scheduler, then it will update
total_tasks.
+ // But the previous 8 tasks may finished and try to access
total_tasks. So that
+ // has to use a lock to protect it.
+ std::lock_guard<std::mutex> l(_task_mutex);
+ _total_tasks = submit_tasks;
+ }
break;
}
submit_tasks++;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]