Coverage Report

Created: 2026-03-13 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/pipeline/pipeline_task.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "exec/pipeline/pipeline_task.h"
19
20
#include <fmt/core.h>
21
#include <fmt/format.h>
22
#include <gen_cpp/Metrics_types.h>
23
#include <glog/logging.h>
24
25
#include <algorithm>
26
#include <memory>
27
#include <ostream>
28
#include <vector>
29
30
#include "common/logging.h"
31
#include "common/status.h"
32
#include "core/block/block.h"
33
#include "exec/operator/exchange_source_operator.h"
34
#include "exec/operator/operator.h"
35
#include "exec/operator/rec_cte_source_operator.h"
36
#include "exec/operator/scan_operator.h"
37
#include "exec/pipeline/dependency.h"
38
#include "exec/pipeline/pipeline.h"
39
#include "exec/pipeline/pipeline_fragment_context.h"
40
#include "exec/pipeline/revokable_task.h"
41
#include "exec/pipeline/task_queue.h"
42
#include "exec/pipeline/task_scheduler.h"
43
#include "exec/spill/spill_stream.h"
44
#include "runtime/descriptors.h"
45
#include "runtime/exec_env.h"
46
#include "runtime/query_context.h"
47
#include "runtime/runtime_profile.h"
48
#include "runtime/thread_context.h"
49
#include "runtime/workload_group/workload_group_manager.h"
50
#include "util/defer_op.h"
51
#include "util/mem_info.h"
52
#include "util/uid_util.h"
53
54
namespace doris {
55
class RuntimeState;
56
} // namespace doris
57
58
namespace doris {
59
#include "common/compile_check_begin.h"
60
61
PipelineTask::PipelineTask(PipelinePtr& pipeline, uint32_t task_id, RuntimeState* state,
62
                           std::shared_ptr<PipelineFragmentContext> fragment_context,
63
                           RuntimeProfile* parent_profile,
64
                           std::map<int, std::pair<std::shared_ptr<BasicSharedState>,
65
                                                   std::vector<std::shared_ptr<Dependency>>>>
66
                                   shared_state_map,
67
                           int task_idx)
68
        :
69
#ifdef BE_TEST
70
          _query_id(fragment_context ? fragment_context->get_query_id() : TUniqueId()),
71
#else
72
2.31M
          _query_id(fragment_context->get_query_id()),
73
#endif
74
2.31M
          _index(task_id),
75
2.31M
          _pipeline(pipeline),
76
2.31M
          _opened(false),
77
2.31M
          _state(state),
78
2.31M
          _fragment_context(fragment_context),
79
2.31M
          _parent_profile(parent_profile),
80
2.31M
          _operators(pipeline->operators()),
81
2.31M
          _source(_operators.front().get()),
82
2.31M
          _root(_operators.back().get()),
83
2.31M
          _sink(pipeline->sink_shared_pointer()),
84
2.31M
          _shared_state_map(std::move(shared_state_map)),
85
2.31M
          _task_idx(task_idx),
86
2.31M
          _memory_sufficient_dependency(state->get_query_ctx()->get_memory_sufficient_dependency()),
87
2.31M
          _pipeline_name(_pipeline->name()) {
88
2.31M
#ifndef BE_TEST
89
2.31M
    _query_mem_tracker = fragment_context->get_query_ctx()->query_mem_tracker();
90
2.31M
#endif
91
2.31M
    _execution_dependencies.push_back(state->get_query_ctx()->get_execution_dependency());
92
2.31M
    if (!_shared_state_map.contains(_sink->dests_id().front())) {
93
1.94M
        auto shared_state = _sink->create_shared_state();
94
1.94M
        if (shared_state) {
95
1.92M
            _sink_shared_state = shared_state;
96
1.92M
        }
97
1.94M
    }
98
2.31M
}
99
100
2.32M
PipelineTask::~PipelineTask() {
101
2.39M
    auto reset_member = [&]() {
102
2.39M
        _shared_state_map.clear();
103
2.39M
        _sink_shared_state.reset();
104
2.39M
        _op_shared_states.clear();
105
2.39M
        _sink.reset();
106
2.39M
        _operators.clear();
107
2.39M
        _block.reset();
108
2.39M
        _pipeline.reset();
109
2.39M
    };
110
// PipelineTask is also hold by task queue( https://github.com/apache/doris/pull/49753),
111
// so that it maybe the last one to be destructed.
112
// But pipeline task hold some objects, like operators, shared state, etc. So that should release
113
// memory manually.
114
2.32M
#ifndef BE_TEST
115
2.32M
    if (_query_mem_tracker) {
116
2.32M
        SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_query_mem_tracker);
117
2.32M
        reset_member();
118
2.32M
        return;
119
2.32M
    }
120
738
#endif
121
738
    reset_member();
122
738
}
123
124
Status PipelineTask::prepare(const std::vector<TScanRangeParams>& scan_range, const int sender_id,
125
2.30M
                             const TDataSink& tsink) {
126
2.30M
    DCHECK(_sink);
127
2.30M
    _init_profile();
128
2.30M
    SCOPED_TIMER(_task_profile->total_time_counter());
129
2.30M
    SCOPED_CPU_TIMER(_task_cpu_timer);
130
2.30M
    SCOPED_TIMER(_prepare_timer);
131
2.30M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::prepare", {
132
2.30M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task prepare failed");
133
2.30M
        return status;
134
2.30M
    });
135
2.30M
    {
136
        // set sink local state
137
2.30M
        LocalSinkStateInfo info {_task_idx,         _task_profile.get(),
138
2.30M
                                 sender_id,         get_sink_shared_state().get(),
139
2.30M
                                 _shared_state_map, tsink};
140
2.30M
        RETURN_IF_ERROR(_sink->setup_local_state(_state, info));
141
2.30M
    }
142
143
2.30M
    _scan_ranges = scan_range;
144
2.30M
    auto* parent_profile = _state->get_sink_local_state()->operator_profile();
145
146
5.31M
    for (int op_idx = cast_set<int>(_operators.size() - 1); op_idx >= 0; op_idx--) {
147
3.00M
        auto& op = _operators[op_idx];
148
3.00M
        LocalStateInfo info {parent_profile, _scan_ranges, get_op_shared_state(op->operator_id()),
149
3.00M
                             _shared_state_map, _task_idx};
150
3.00M
        RETURN_IF_ERROR(op->setup_local_state(_state, info));
151
3.00M
        parent_profile = _state->get_local_state(op->operator_id())->operator_profile();
152
3.00M
    }
153
2.30M
    {
154
2.30M
        const auto& deps =
155
2.30M
                _state->get_local_state(_source->operator_id())->execution_dependencies();
156
2.30M
        std::unique_lock<std::mutex> lc(_dependency_lock);
157
2.30M
        std::copy(deps.begin(), deps.end(),
158
2.30M
                  std::inserter(_execution_dependencies, _execution_dependencies.end()));
159
2.30M
    }
160
2.31M
    if (auto fragment = _fragment_context.lock()) {
161
2.31M
        if (fragment->get_query_ctx()->is_cancelled()) {
162
0
            terminate();
163
0
            return fragment->get_query_ctx()->exec_status();
164
0
        }
165
18.4E
    } else {
166
18.4E
        return Status::InternalError("Fragment already finished! Query: {}", print_id(_query_id));
167
18.4E
    }
168
2.31M
    _block = doris::Block::create_unique();
169
2.31M
    return _state_transition(State::RUNNABLE);
170
2.30M
}
171
172
2.31M
Status PipelineTask::_extract_dependencies() {
173
2.31M
    std::vector<std::vector<Dependency*>> read_dependencies;
174
2.31M
    std::vector<Dependency*> write_dependencies;
175
2.31M
    std::vector<Dependency*> finish_dependencies;
176
2.31M
    read_dependencies.resize(_operators.size());
177
2.31M
    size_t i = 0;
178
3.00M
    for (auto& op : _operators) {
179
3.00M
        auto* local_state = _state->get_local_state(op->operator_id());
180
3.00M
        DCHECK(local_state);
181
3.00M
        read_dependencies[i] = local_state->dependencies();
182
3.00M
        auto* fin_dep = local_state->finishdependency();
183
3.00M
        if (fin_dep) {
184
8
            finish_dependencies.push_back(fin_dep);
185
8
        }
186
3.00M
        i++;
187
3.00M
    }
188
2.31M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::_extract_dependencies", {
189
2.31M
        Status status = Status::Error<INTERNAL_ERROR>(
190
2.31M
                "fault_inject pipeline_task _extract_dependencies failed");
191
2.31M
        return status;
192
2.31M
    });
193
2.31M
    {
194
2.31M
        auto* local_state = _state->get_sink_local_state();
195
2.31M
        write_dependencies = local_state->dependencies();
196
2.31M
        auto* fin_dep = local_state->finishdependency();
197
2.31M
        if (fin_dep) {
198
990k
            finish_dependencies.push_back(fin_dep);
199
990k
        }
200
2.31M
    }
201
2.31M
    {
202
2.31M
        std::unique_lock<std::mutex> lc(_dependency_lock);
203
2.31M
        read_dependencies.swap(_read_dependencies);
204
2.31M
        write_dependencies.swap(_write_dependencies);
205
2.31M
        finish_dependencies.swap(_finish_dependencies);
206
2.31M
    }
207
2.31M
    return Status::OK();
208
2.31M
}
209
210
1.33M
bool PipelineTask::inject_shared_state(std::shared_ptr<BasicSharedState> shared_state) {
211
1.33M
    if (!shared_state) {
212
710k
        return false;
213
710k
    }
214
    // Shared state is created by upstream task's sink operator and shared by source operator of
215
    // this task.
216
735k
    for (auto& op : _operators) {
217
735k
        if (shared_state->related_op_ids.contains(op->operator_id())) {
218
609k
            _op_shared_states.insert({op->operator_id(), shared_state});
219
609k
            return true;
220
609k
        }
221
735k
    }
222
    // Shared state is created by the first sink operator and shared by sink operator of this task.
223
    // For example, Set operations.
224
12.4k
    if (shared_state->related_op_ids.contains(_sink->dests_id().front())) {
225
12.4k
        DCHECK_EQ(_sink_shared_state, nullptr)
226
0
                << " Sink: " << _sink->get_name() << " dest id: " << _sink->dests_id().front();
227
12.4k
        _sink_shared_state = shared_state;
228
12.4k
        return true;
229
12.4k
    }
230
18.4E
    return false;
231
10.8k
}
232
233
2.31M
void PipelineTask::_init_profile() {
234
2.31M
    _task_profile = std::make_unique<RuntimeProfile>(fmt::format("PipelineTask(index={})", _index));
235
2.31M
    _parent_profile->add_child(_task_profile.get(), true, nullptr);
236
2.31M
    _task_cpu_timer = ADD_TIMER(_task_profile, "TaskCpuTime");
237
238
2.31M
    static const char* exec_time = "ExecuteTime";
239
2.31M
    _exec_timer = ADD_TIMER(_task_profile, exec_time);
240
2.31M
    _prepare_timer = ADD_CHILD_TIMER(_task_profile, "PrepareTime", exec_time);
241
2.31M
    _open_timer = ADD_CHILD_TIMER(_task_profile, "OpenTime", exec_time);
242
2.31M
    _get_block_timer = ADD_CHILD_TIMER(_task_profile, "GetBlockTime", exec_time);
243
2.31M
    _get_block_counter = ADD_COUNTER(_task_profile, "GetBlockCounter", TUnit::UNIT);
244
2.31M
    _sink_timer = ADD_CHILD_TIMER(_task_profile, "SinkTime", exec_time);
245
2.31M
    _close_timer = ADD_CHILD_TIMER(_task_profile, "CloseTime", exec_time);
246
247
2.31M
    _wait_worker_timer = ADD_TIMER_WITH_LEVEL(_task_profile, "WaitWorkerTime", 1);
248
249
2.31M
    _schedule_counts = ADD_COUNTER(_task_profile, "NumScheduleTimes", TUnit::UNIT);
250
2.31M
    _yield_counts = ADD_COUNTER(_task_profile, "NumYieldTimes", TUnit::UNIT);
251
2.31M
    _core_change_times = ADD_COUNTER(_task_profile, "CoreChangeTimes", TUnit::UNIT);
252
2.31M
    _memory_reserve_times = ADD_COUNTER(_task_profile, "MemoryReserveTimes", TUnit::UNIT);
253
2.31M
    _memory_reserve_failed_times =
254
2.31M
            ADD_COUNTER(_task_profile, "MemoryReserveFailedTimes", TUnit::UNIT);
255
2.31M
}
256
257
2.31M
void PipelineTask::_fresh_profile_counter() {
258
2.31M
    COUNTER_SET(_schedule_counts, (int64_t)_schedule_time);
259
2.31M
    COUNTER_SET(_wait_worker_timer, (int64_t)_wait_worker_watcher.elapsed_time());
260
2.31M
}
261
262
2.31M
Status PipelineTask::_open() {
263
2.31M
    SCOPED_TIMER(_task_profile->total_time_counter());
264
2.31M
    SCOPED_CPU_TIMER(_task_cpu_timer);
265
2.31M
    SCOPED_TIMER(_open_timer);
266
2.31M
    _dry_run = _sink->should_dry_run(_state);
267
3.01M
    for (auto& o : _operators) {
268
3.01M
        RETURN_IF_ERROR(_state->get_local_state(o->operator_id())->open(_state));
269
3.01M
    }
270
2.31M
    RETURN_IF_ERROR(_state->get_sink_local_state()->open(_state));
271
2.31M
    RETURN_IF_ERROR(_extract_dependencies());
272
2.31M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::open", {
273
2.31M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task open failed");
274
2.31M
        return status;
275
2.31M
    });
276
2.31M
    _opened = true;
277
2.31M
    return Status::OK();
278
2.31M
}
279
280
13.3M
Status PipelineTask::_prepare() {
281
13.3M
    SCOPED_TIMER(_task_profile->total_time_counter());
282
13.3M
    SCOPED_CPU_TIMER(_task_cpu_timer);
283
16.9M
    for (auto& o : _operators) {
284
16.9M
        RETURN_IF_ERROR(_state->get_local_state(o->operator_id())->prepare(_state));
285
16.9M
    }
286
13.3M
    RETURN_IF_ERROR(_state->get_sink_local_state()->prepare(_state));
287
13.3M
    return Status::OK();
288
13.3M
}
289
290
7.70M
bool PipelineTask::_wait_to_start() {
291
    // Before task starting, we should make sure
292
    // 1. Execution dependency is ready (which is controlled by FE 2-phase commit)
293
    // 2. Runtime filter dependencies are ready
294
    // 3. All tablets are loaded into local storage
295
7.70M
    return std::any_of(
296
7.70M
            _execution_dependencies.begin(), _execution_dependencies.end(),
297
9.11M
            [&](Dependency* dep) -> bool { return dep->is_blocked_by(shared_from_this()); });
298
7.70M
}
299
300
2.70M
bool PipelineTask::_is_pending_finish() {
301
    // Spilling may be in progress if eos is true.
302
2.70M
    return std::ranges::any_of(_finish_dependencies, [&](Dependency* dep) -> bool {
303
1.39M
        return dep->is_blocked_by(shared_from_this());
304
1.39M
    });
305
2.70M
}
306
307
8.11M
bool PipelineTask::is_blockable() const {
308
    // Before task starting, we should make sure
309
    // 1. Execution dependency is ready (which is controlled by FE 2-phase commit)
310
    // 2. Runtime filter dependencies are ready
311
    // 3. All tablets are loaded into local storage
312
313
8.11M
    if (_state->enable_fuzzy_blockable_task()) {
314
16.2k
        if ((_schedule_time + _task_idx) % 2 == 0) {
315
9.06k
            return true;
316
9.06k
        }
317
16.2k
    }
318
319
8.10M
    return std::ranges::any_of(_operators,
320
10.4M
                               [&](OperatorPtr op) -> bool { return op->is_blockable(_state); }) ||
321
8.11M
           _sink->is_blockable(_state);
322
8.11M
}
323
324
10.1M
bool PipelineTask::_is_blocked() {
325
    // `_dry_run = true` means we do not need data from source operator.
326
10.1M
    if (!_dry_run) {
327
18.4M
        for (int i = cast_set<int>(_read_dependencies.size() - 1); i >= 0; i--) {
328
            // `_read_dependencies` is organized according to operators. For each operator, running condition is met iff all dependencies are ready.
329
14.1M
            for (auto* dep : _read_dependencies[i]) {
330
14.1M
                if (dep->is_blocked_by(shared_from_this())) {
331
3.20M
                    return true;
332
3.20M
                }
333
14.1M
            }
334
            // If all dependencies are ready for this operator, we can execute this task if no datum is needed from upstream operators.
335
8.41M
            if (!_operators[i]->need_more_input_data(_state)) {
336
87.6k
                break;
337
87.6k
            }
338
8.41M
        }
339
10.1M
    }
340
6.97M
    return _memory_sufficient_dependency->is_blocked_by(shared_from_this()) ||
341
10.6M
           std::ranges::any_of(_write_dependencies, [&](Dependency* dep) -> bool {
342
10.6M
               return dep->is_blocked_by(shared_from_this());
343
10.6M
           });
344
10.1M
}
345
346
1.40M
void PipelineTask::terminate() {
347
    // We use a lock to assure all dependencies are not deconstructed here.
348
1.40M
    std::unique_lock<std::mutex> lc(_dependency_lock);
349
1.40M
    auto fragment = _fragment_context.lock();
350
1.40M
    if (!is_finalized() && fragment) {
351
57.0k
        try {
352
57.0k
            DCHECK(_wake_up_early || fragment->is_canceled());
353
57.0k
            std::ranges::for_each(_write_dependencies,
354
155k
                                  [&](Dependency* dep) { dep->set_always_ready(); });
355
57.0k
            std::ranges::for_each(_finish_dependencies,
356
57.0k
                                  [&](Dependency* dep) { dep->set_always_ready(); });
357
63.7k
            std::ranges::for_each(_read_dependencies, [&](std::vector<Dependency*>& deps) {
358
73.3k
                std::ranges::for_each(deps, [&](Dependency* dep) { dep->set_always_ready(); });
359
63.7k
            });
360
            // All `_execution_deps` will never be set blocking from ready. So we just set ready here.
361
57.0k
            std::ranges::for_each(_execution_dependencies,
362
71.6k
                                  [&](Dependency* dep) { dep->set_ready(); });
363
57.0k
            _memory_sufficient_dependency->set_ready();
364
57.0k
        } catch (const doris::Exception& e) {
365
0
            LOG(WARNING) << "Terminate failed: " << e.code() << ", " << e.to_string();
366
0
        }
367
57.0k
    }
368
1.40M
}
369
370
/**
371
 * `_eos` indicates whether the execution phase is done. `done` indicates whether we could close
372
 * this task.
373
 *
374
 * For example,
375
 * 1. if `_eos` is false which means we should continue to get next block so we cannot close (e.g.
376
 *    `done` is false)
377
 * 2. if `_eos` is true which means all blocks from source are exhausted but `_is_pending_finish()`
378
 *    is true which means we should wait for a pending dependency ready (maybe a running rpc), so we
379
 *    cannot close (e.g. `done` is false)
380
 * 3. if `_eos` is true which means all blocks from source are exhausted and `_is_pending_finish()`
381
 *    is false which means we can close immediately (e.g. `done` is true)
382
 * @param done
383
 * @return
384
 */
385
8.12M
Status PipelineTask::execute(bool* done) {
386
8.12M
    if (_exec_state != State::RUNNABLE || _blocked_dep != nullptr) [[unlikely]] {
387
#ifdef BE_TEST
388
        return Status::InternalError("Pipeline task is not runnable! Task info: {}",
389
                                     debug_string());
390
#else
391
1
        return Status::FatalError("Pipeline task is not runnable! Task info: {}", debug_string());
392
1
#endif
393
1
    }
394
395
8.12M
    auto fragment_context = _fragment_context.lock();
396
8.12M
    if (!fragment_context) {
397
0
        return Status::InternalError("Fragment already finished! Query: {}", print_id(_query_id));
398
0
    }
399
8.12M
    int64_t time_spent = 0;
400
8.12M
    ThreadCpuStopWatch cpu_time_stop_watch;
401
8.12M
    cpu_time_stop_watch.start();
402
8.12M
    SCOPED_ATTACH_TASK(_state);
403
8.12M
    Defer running_defer {[&]() {
404
8.10M
        int64_t delta_cpu_time = cpu_time_stop_watch.elapsed_time();
405
8.10M
        _task_cpu_timer->update(delta_cpu_time);
406
8.10M
        fragment_context->get_query_ctx()->resource_ctx()->cpu_context()->update_cpu_cost_ms(
407
8.10M
                delta_cpu_time);
408
409
        // If task is woke up early, we should terminate all operators, and this task could be closed immediately.
410
8.10M
        if (_wake_up_early) {
411
7.87k
            terminate();
412
7.87k
            THROW_IF_ERROR(_root->terminate(_state));
413
7.87k
            THROW_IF_ERROR(_sink->terminate(_state));
414
7.87k
            _eos = true;
415
7.87k
            *done = true;
416
8.09M
        } else if (_eos && !_spilling &&
417
8.09M
                   (fragment_context->is_canceled() || !_is_pending_finish())) {
418
2.30M
            *done = true;
419
2.30M
        }
420
8.10M
    }};
421
8.12M
    const auto query_id = _state->query_id();
422
    // If this task is already EOS and block is empty (which means we already output all blocks),
423
    // just return here.
424
8.12M
    if (_eos && !_spilling) {
425
399k
        return Status::OK();
426
399k
    }
427
    // If this task is blocked by a spilling request and waken up immediately, the spilling
428
    // dependency will not block this task and we should just run here.
429
7.72M
    if (!_block->empty()) {
430
0
        LOG(INFO) << "Query: " << print_id(query_id) << " has pending block, size: "
431
0
                  << PrettyPrinter::print_bytes(_block->allocated_bytes());
432
0
        DCHECK(_spilling);
433
0
    }
434
435
7.72M
    SCOPED_TIMER(_task_profile->total_time_counter());
436
7.72M
    SCOPED_TIMER(_exec_timer);
437
438
7.72M
    if (!_wake_up_early) {
439
7.72M
        RETURN_IF_ERROR(_prepare());
440
7.72M
    }
441
7.72M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::execute", {
442
7.72M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task execute failed");
443
7.72M
        return status;
444
7.72M
    });
445
    // `_wake_up_early` must be after `_wait_to_start()`
446
7.72M
    if (_wait_to_start() || _wake_up_early) {
447
2.10M
        return Status::OK();
448
2.10M
    }
449
5.61M
    RETURN_IF_ERROR(_prepare());
450
451
    // The status must be runnable
452
5.61M
    if (!_opened && !fragment_context->is_canceled()) {
453
2.31M
        DBUG_EXECUTE_IF("PipelineTask::execute.open_sleep", {
454
2.31M
            auto required_pipeline_id =
455
2.31M
                    DebugPoints::instance()->get_debug_param_or_default<int32_t>(
456
2.31M
                            "PipelineTask::execute.open_sleep", "pipeline_id", -1);
457
2.31M
            auto required_task_id = DebugPoints::instance()->get_debug_param_or_default<int32_t>(
458
2.31M
                    "PipelineTask::execute.open_sleep", "task_id", -1);
459
2.31M
            if (required_pipeline_id == pipeline_id() && required_task_id == task_id()) {
460
2.31M
                LOG(WARNING) << "PipelineTask::execute.open_sleep sleep 5s";
461
2.31M
                sleep(5);
462
2.31M
            }
463
2.31M
        });
464
465
2.31M
        SCOPED_RAW_TIMER(&time_spent);
466
2.31M
        RETURN_IF_ERROR(_open());
467
2.31M
    }
468
469
10.1M
    while (!fragment_context->is_canceled()) {
470
10.1M
        SCOPED_RAW_TIMER(&time_spent);
471
10.1M
        Defer defer {[&]() {
472
            // If this run is pended by a spilling request, the block will be output in next run.
473
10.1M
            if (!_spilling) {
474
10.1M
                _block->clear_column_data(_root->row_desc().num_materialized_slots());
475
10.1M
            }
476
10.1M
        }};
477
        // `_wake_up_early` must be after `_is_blocked()`
478
10.1M
        if (_is_blocked() || _wake_up_early) {
479
3.22M
            return Status::OK();
480
3.22M
        }
481
482
        /// When a task is cancelled,
483
        /// its blocking state will be cleared and it will transition to a ready state (though it is not truly ready).
484
        /// Here, checking whether it is cancelled to prevent tasks in a blocking state from being re-executed.
485
6.96M
        if (fragment_context->is_canceled()) {
486
3
            break;
487
3
        }
488
489
6.96M
        if (time_spent > _exec_time_slice) {
490
69.0k
            COUNTER_UPDATE(_yield_counts, 1);
491
69.0k
            break;
492
69.0k
        }
493
6.89M
        auto* block = _block.get();
494
495
6.89M
        DBUG_EXECUTE_IF("fault_inject::PipelineXTask::executing", {
496
6.89M
            Status status =
497
6.89M
                    Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task executing failed");
498
6.89M
            return status;
499
6.89M
        });
500
501
        // `_sink->is_finished(_state)` means sink operator should be finished
502
6.89M
        if (_sink->is_finished(_state)) {
503
8
            set_wake_up_early();
504
8
            return Status::OK();
505
8
        }
506
507
        // `_dry_run` means sink operator need no more data
508
6.89M
        _eos = _dry_run || _eos;
509
6.89M
        _spilling = false;
510
6.89M
        auto workload_group = _state->workload_group();
511
        // If last run is pended by a spilling request, `_block` is produced with some rows in last
512
        // run, so we will resume execution using the block.
513
6.89M
        if (!_eos && _block->empty()) {
514
6.87M
            SCOPED_TIMER(_get_block_timer);
515
6.87M
            if (_state->low_memory_mode()) {
516
9.94k
                _sink->set_low_memory_mode(_state);
517
9.94k
                _root->set_low_memory_mode(_state);
518
9.94k
            }
519
6.87M
            DEFER_RELEASE_RESERVED();
520
6.87M
            _get_block_counter->update(1);
521
6.87M
            const auto reserve_size = _root->get_reserve_mem_size(_state);
522
6.87M
            _root->reset_reserve_mem_size(_state);
523
524
6.87M
            if (workload_group &&
525
6.87M
                _state->get_query_ctx()
526
6.03M
                        ->resource_ctx()
527
6.03M
                        ->task_controller()
528
6.03M
                        ->is_enable_reserve_memory() &&
529
6.87M
                reserve_size > 0) {
530
5.98M
                if (!_try_to_reserve_memory(reserve_size, _root)) {
531
1.95k
                    continue;
532
1.95k
                }
533
5.98M
            }
534
535
6.86M
            bool eos = false;
536
6.86M
            RETURN_IF_ERROR(_root->get_block_after_projects(_state, block, &eos));
537
6.86M
            RETURN_IF_ERROR(block->check_type_and_column());
538
6.86M
            _eos = eos;
539
6.86M
        }
540
541
6.88M
        if (!_block->empty() || _eos) {
542
3.13M
            SCOPED_TIMER(_sink_timer);
543
3.13M
            Status status = Status::OK();
544
3.13M
            DEFER_RELEASE_RESERVED();
545
3.13M
            if (_state->get_query_ctx()
546
3.13M
                        ->resource_ctx()
547
3.13M
                        ->task_controller()
548
3.13M
                        ->is_enable_reserve_memory() &&
549
3.13M
                workload_group && !(_wake_up_early || _dry_run)) {
550
3.11M
                const auto sink_reserve_size = _sink->get_reserve_mem_size(_state, _eos);
551
3.11M
                if (sink_reserve_size > 0 &&
552
3.11M
                    !_try_to_reserve_memory(sink_reserve_size, _sink.get())) {
553
929
                    continue;
554
929
                }
555
3.11M
            }
556
557
3.13M
            DBUG_EXECUTE_IF("PipelineTask::execute.sink_eos_sleep", {
558
3.13M
                auto required_pipeline_id =
559
3.13M
                        DebugPoints::instance()->get_debug_param_or_default<int32_t>(
560
3.13M
                                "PipelineTask::execute.sink_eos_sleep", "pipeline_id", -1);
561
3.13M
                auto required_task_id =
562
3.13M
                        DebugPoints::instance()->get_debug_param_or_default<int32_t>(
563
3.13M
                                "PipelineTask::execute.sink_eos_sleep", "task_id", -1);
564
3.13M
                if (required_pipeline_id == pipeline_id() && required_task_id == task_id()) {
565
3.13M
                    LOG(WARNING) << "PipelineTask::execute.sink_eos_sleep sleep 10s";
566
3.13M
                    sleep(10);
567
3.13M
                }
568
3.13M
            });
569
570
3.13M
            DBUG_EXECUTE_IF("PipelineTask::execute.terminate", {
571
3.13M
                if (_eos) {
572
3.13M
                    auto required_pipeline_id =
573
3.13M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
574
3.13M
                                    "PipelineTask::execute.terminate", "pipeline_id", -1);
575
3.13M
                    auto required_task_id =
576
3.13M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
577
3.13M
                                    "PipelineTask::execute.terminate", "task_id", -1);
578
3.13M
                    auto required_fragment_id =
579
3.13M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
580
3.13M
                                    "PipelineTask::execute.terminate", "fragment_id", -1);
581
3.13M
                    if (required_pipeline_id == pipeline_id() && required_task_id == task_id() &&
582
3.13M
                        fragment_context->get_fragment_id() == required_fragment_id) {
583
3.13M
                        _wake_up_early = true;
584
3.13M
                        terminate();
585
3.13M
                    } else if (required_pipeline_id == pipeline_id() &&
586
3.13M
                               fragment_context->get_fragment_id() == required_fragment_id) {
587
3.13M
                        LOG(WARNING) << "PipelineTask::execute.terminate sleep 5s";
588
3.13M
                        sleep(5);
589
3.13M
                    }
590
3.13M
                }
591
3.13M
            });
592
3.13M
            RETURN_IF_ERROR(block->check_type_and_column());
593
3.13M
            status = _sink->sink(_state, block, _eos);
594
595
3.13M
            if (_eos) {
596
2.31M
                if (_sink->reset_to_rerun(_state, _root)) {
597
1.87k
                    _eos = false;
598
2.31M
                } else {
599
2.31M
                    RETURN_IF_ERROR(close(Status::OK(), false));
600
2.31M
                }
601
2.31M
            }
602
603
3.13M
            if (status.is<ErrorCode::END_OF_FILE>()) {
604
27
                set_wake_up_early();
605
27
                return Status::OK();
606
3.13M
            } else if (!status) {
607
15
                return status;
608
15
            }
609
610
3.13M
            if (_eos) { // just return, the scheduler will do finish work
611
2.31M
                return Status::OK();
612
2.31M
            }
613
3.13M
        }
614
6.88M
    }
615
616
73.8k
    RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(shared_from_this()));
617
73.8k
    return Status::OK();
618
73.8k
}
619
620
1.01k
Status PipelineTask::do_revoke_memory(const std::shared_ptr<SpillContext>& spill_context) {
621
1.01k
    auto fragment_context = _fragment_context.lock();
622
1.01k
    if (!fragment_context) {
623
0
        return Status::InternalError("Fragment already finished! Query: {}", print_id(_query_id));
624
0
    }
625
626
1.01k
    SCOPED_ATTACH_TASK(_state);
627
1.01k
    ThreadCpuStopWatch cpu_time_stop_watch;
628
1.01k
    cpu_time_stop_watch.start();
629
1.01k
    Defer running_defer {[&]() {
630
1.01k
        int64_t delta_cpu_time = cpu_time_stop_watch.elapsed_time();
631
1.01k
        _task_cpu_timer->update(delta_cpu_time);
632
1.01k
        fragment_context->get_query_ctx()->resource_ctx()->cpu_context()->update_cpu_cost_ms(
633
1.01k
                delta_cpu_time);
634
635
        // If task is woke up early, we should terminate all operators, and this task could be closed immediately.
636
1.01k
        if (_wake_up_early) {
637
0
            terminate();
638
0
            THROW_IF_ERROR(_root->terminate(_state));
639
0
            THROW_IF_ERROR(_sink->terminate(_state));
640
0
            _eos = true;
641
0
        }
642
1.01k
    }};
643
644
1.01k
    return _sink->revoke_memory(_state, spill_context);
645
1.01k
}
646
647
8.83M
bool PipelineTask::_try_to_reserve_memory(const size_t reserve_size, OperatorBase* op) {
648
8.83M
    auto st = thread_context()->thread_mem_tracker_mgr->try_reserve(reserve_size);
649
    // If reserve memory failed and the query is not enable spill, just disable reserve memory(this will enable
650
    // memory hard limit check, and will cancel the query if allocate memory failed) and let it run.
651
8.83M
    if (!st.ok() && !_state->enable_spill()) {
652
2
        LOG(INFO) << print_id(_query_id) << " reserve memory failed due to " << st
653
2
                  << ", and it is not enable spill, disable reserve memory and let it run";
654
2
        _state->get_query_ctx()->resource_ctx()->task_controller()->disable_reserve_memory();
655
2
        return true;
656
2
    }
657
8.83M
    COUNTER_UPDATE(_memory_reserve_times, 1);
658
8.83M
    auto sink_revocable_mem_size = _sink->revocable_mem_size(_state);
659
8.84M
    if (st.ok() && _state->enable_force_spill() && _sink->is_spillable() &&
660
8.83M
        sink_revocable_mem_size >= SpillStream::MIN_SPILL_WRITE_BATCH_MEM) {
661
1.01k
        st = Status(ErrorCode::QUERY_MEMORY_EXCEEDED, "Force Spill");
662
1.01k
    }
663
8.83M
    if (!st.ok()) {
664
2.88k
        COUNTER_UPDATE(_memory_reserve_failed_times, 1);
665
2.88k
        auto debug_msg = fmt::format(
666
2.88k
                "Query: {} , try to reserve: {}, operator name: {}, operator "
667
2.88k
                "id: {}, task id: {}, root revocable mem size: {}, sink revocable mem"
668
2.88k
                "size: {}, failed: {}",
669
2.88k
                print_id(_query_id), PrettyPrinter::print_bytes(reserve_size), op->get_name(),
670
2.88k
                op->node_id(), _state->task_id(),
671
2.88k
                PrettyPrinter::print_bytes(op->revocable_mem_size(_state)),
672
2.88k
                PrettyPrinter::print_bytes(sink_revocable_mem_size), st.to_string());
673
        // PROCESS_MEMORY_EXCEEDED error msg already contains process_mem_log_str
674
2.88k
        if (!st.is<ErrorCode::PROCESS_MEMORY_EXCEEDED>()) {
675
2.88k
            debug_msg +=
676
2.88k
                    fmt::format(", debug info: {}", GlobalMemoryArbitrator::process_mem_log_str());
677
2.88k
        }
678
        // If sink has enough revocable memory, trigger revoke memory
679
2.88k
        LOG(INFO) << fmt::format(
680
2.88k
                "Query: {} sink: {}, node id: {}, task id: "
681
2.88k
                "{}, revocable mem size: {}",
682
2.88k
                print_id(_query_id), _sink->get_name(), _sink->node_id(), _state->task_id(),
683
2.88k
                PrettyPrinter::print_bytes(sink_revocable_mem_size));
684
2.88k
        ExecEnv::GetInstance()->workload_group_mgr()->add_paused_query(
685
2.88k
                _state->get_query_ctx()->resource_ctx()->shared_from_this(), reserve_size, st);
686
2.88k
        _spilling = true;
687
2.88k
        return false;
688
        // !!! Attention:
689
        // In the past, if reserve failed, not add this query to paused list, because it is very small, will not
690
        // consume a lot of memory. But need set low memory mode to indicate that the system should
691
        // not use too much memory.
692
        // But if we only set _state->get_query_ctx()->set_low_memory_mode() here, and return true, the query will
693
        // continue to run and not blocked, and this reserve maybe the last block of join sink opertorator, and it will
694
        // build hash table directly and will consume a lot of memory. So that should return false directly.
695
        // TODO: we should using a global system buffer management logic to deal with low memory mode.
696
        /**
697
        if (sink_revocable_mem_size >= SpillStream::MIN_SPILL_WRITE_BATCH_MEM) {
698
            LOG(INFO) << fmt::format(
699
                    "Query: {} sink: {}, node id: {}, task id: "
700
                    "{}, revocable mem size: {}",
701
                    print_id(_query_id), _sink->get_name(), _sink->node_id(), _state->task_id(),
702
                    PrettyPrinter::print_bytes(sink_revocable_mem_size));
703
            ExecEnv::GetInstance()->workload_group_mgr()->add_paused_query(
704
                    _state->get_query_ctx()->resource_ctx()->shared_from_this(), reserve_size, st);
705
            _spilling = true;
706
            return false;
707
        } else {
708
            _state->get_query_ctx()->set_low_memory_mode();
709
        } */
710
2.88k
    }
711
8.82M
    return true;
712
8.83M
}
713
714
1.48M
void PipelineTask::stop_if_finished() {
715
1.48M
    auto fragment = _fragment_context.lock();
716
1.48M
    if (!fragment) {
717
0
        return;
718
0
    }
719
1.48M
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(fragment->get_query_ctx()->query_mem_tracker());
720
1.48M
    if (auto sink = _sink) {
721
1.21M
        if (sink->is_finished(_state)) {
722
2.62k
            set_wake_up_early();
723
2.62k
            terminate();
724
2.62k
        }
725
1.21M
    }
726
1.48M
}
727
728
2.31M
Status PipelineTask::finalize() {
729
2.31M
    auto fragment = _fragment_context.lock();
730
2.31M
    if (!fragment) {
731
0
        return Status::OK();
732
0
    }
733
2.31M
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(fragment->get_query_ctx()->query_mem_tracker());
734
2.31M
    RETURN_IF_ERROR(_state_transition(State::FINALIZED));
735
2.31M
    std::unique_lock<std::mutex> lc(_dependency_lock);
736
2.31M
    _sink_shared_state.reset();
737
2.31M
    _op_shared_states.clear();
738
2.31M
    _shared_state_map.clear();
739
2.31M
    _block.reset();
740
2.31M
    _operators.clear();
741
2.31M
    _sink.reset();
742
2.31M
    _pipeline.reset();
743
2.31M
    return Status::OK();
744
2.31M
}
745
746
4.62M
Status PipelineTask::close(Status exec_status, bool close_sink) {
747
4.62M
    int64_t close_ns = 0;
748
4.62M
    Status s;
749
4.62M
    {
750
4.62M
        SCOPED_RAW_TIMER(&close_ns);
751
4.62M
        if (close_sink) {
752
2.32M
            s = _sink->close(_state, exec_status);
753
2.32M
        }
754
6.02M
        for (auto& op : _operators) {
755
6.02M
            auto tem = op->close(_state);
756
6.02M
            if (!tem.ok() && s.ok()) {
757
5
                s = std::move(tem);
758
5
            }
759
6.02M
        }
760
4.62M
    }
761
4.63M
    if (_opened) {
762
4.63M
        COUNTER_UPDATE(_close_timer, close_ns);
763
4.63M
        COUNTER_UPDATE(_task_profile->total_time_counter(), close_ns);
764
4.63M
    }
765
766
4.62M
    if (close_sink && _opened) {
767
2.32M
        _task_profile->add_info_string("WakeUpEarly", std::to_string(_wake_up_early.load()));
768
2.32M
        _fresh_profile_counter();
769
2.32M
    }
770
771
4.62M
    if (close_sink) {
772
2.31M
        RETURN_IF_ERROR(_state_transition(State::FINISHED));
773
2.31M
    }
774
4.62M
    return s;
775
4.62M
}
776
777
55.2k
std::string PipelineTask::debug_string() {
778
55.2k
    fmt::memory_buffer debug_string_buffer;
779
780
55.2k
    fmt::format_to(debug_string_buffer, "QueryId: {}\n", print_id(_query_id));
781
55.2k
    fmt::format_to(debug_string_buffer, "InstanceId: {}\n",
782
55.2k
                   print_id(_state->fragment_instance_id()));
783
784
55.2k
    fmt::format_to(debug_string_buffer,
785
55.2k
                   "PipelineTask[id = {}, open = {}, eos = {}, state = {}, dry run = "
786
55.2k
                   "{}, _wake_up_early = {}, _wake_up_by = {}, time elapsed since last state "
787
55.2k
                   "changing = {}s, spilling = {}, is running = {}]",
788
55.2k
                   _index, _opened, _eos, _to_string(_exec_state), _dry_run, _wake_up_early.load(),
789
55.2k
                   _wake_by, _state_change_watcher.elapsed_time() / NANOS_PER_SEC, _spilling,
790
55.2k
                   is_running());
791
55.2k
    std::unique_lock<std::mutex> lc(_dependency_lock);
792
55.2k
    auto* cur_blocked_dep = _blocked_dep;
793
55.2k
    auto fragment = _fragment_context.lock();
794
55.2k
    if (is_finalized() || !fragment) {
795
1.15k
        fmt::format_to(debug_string_buffer, " pipeline name = {}", _pipeline_name);
796
1.15k
        return fmt::to_string(debug_string_buffer);
797
1.15k
    }
798
54.0k
    auto elapsed = fragment->elapsed_time() / NANOS_PER_SEC;
799
54.0k
    fmt::format_to(debug_string_buffer, " elapse time = {}s, block dependency = [{}]\n", elapsed,
800
54.0k
                   cur_blocked_dep && !is_finalized() ? cur_blocked_dep->debug_string() : "NULL");
801
802
54.0k
    if (_state && _state->local_runtime_filter_mgr()) {
803
197
        fmt::format_to(debug_string_buffer, "local_runtime_filter_mgr: [{}]\n",
804
197
                       _state->local_runtime_filter_mgr()->debug_string());
805
197
    }
806
807
54.0k
    fmt::format_to(debug_string_buffer, "operators: ");
808
108k
    for (size_t i = 0; i < _operators.size(); i++) {
809
54.0k
        fmt::format_to(debug_string_buffer, "\n{}",
810
54.0k
                       _opened && !is_finalized()
811
54.0k
                               ? _operators[i]->debug_string(_state, cast_set<int>(i))
812
54.0k
                               : _operators[i]->debug_string(cast_set<int>(i)));
813
54.0k
    }
814
54.0k
    fmt::format_to(debug_string_buffer, "\n{}\n",
815
54.0k
                   _opened && !is_finalized()
816
54.0k
                           ? _sink->debug_string(_state, cast_set<int>(_operators.size()))
817
54.0k
                           : _sink->debug_string(cast_set<int>(_operators.size())));
818
819
54.0k
    fmt::format_to(debug_string_buffer, "\nRead Dependency Information: \n");
820
821
54.0k
    size_t i = 0;
822
108k
    for (; i < _read_dependencies.size(); i++) {
823
108k
        for (size_t j = 0; j < _read_dependencies[i].size(); j++) {
824
54.0k
            fmt::format_to(debug_string_buffer, "{}. {}\n", i,
825
54.0k
                           _read_dependencies[i][j]->debug_string(cast_set<int>(i) + 1));
826
54.0k
        }
827
54.0k
    }
828
829
54.0k
    fmt::format_to(debug_string_buffer, "{}. {}\n", i,
830
54.0k
                   _memory_sufficient_dependency->debug_string(cast_set<int>(i++)));
831
832
54.0k
    fmt::format_to(debug_string_buffer, "\nWrite Dependency Information: \n");
833
108k
    for (size_t j = 0; j < _write_dependencies.size(); j++, i++) {
834
54.2k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
835
54.2k
                       _write_dependencies[j]->debug_string(cast_set<int>(j) + 1));
836
54.2k
    }
837
838
54.0k
    fmt::format_to(debug_string_buffer, "\nExecution Dependency Information: \n");
839
162k
    for (size_t j = 0; j < _execution_dependencies.size(); j++, i++) {
840
108k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
841
108k
                       _execution_dependencies[j]->debug_string(cast_set<int>(i) + 1));
842
108k
    }
843
844
54.0k
    fmt::format_to(debug_string_buffer, "Finish Dependency Information: \n");
845
161k
    for (size_t j = 0; j < _finish_dependencies.size(); j++, i++) {
846
107k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
847
107k
                       _finish_dependencies[j]->debug_string(cast_set<int>(i) + 1));
848
107k
    }
849
54.0k
    return fmt::to_string(debug_string_buffer);
850
55.2k
}
851
852
38.0k
size_t PipelineTask::get_revocable_size() const {
853
38.0k
    if (!_opened || is_finalized() || _running || (_eos && !_spilling)) {
854
6.33k
        return 0;
855
6.33k
    }
856
857
31.7k
    return _sink->revocable_mem_size(_state);
858
38.0k
}
859
860
1.01k
Status PipelineTask::revoke_memory(const std::shared_ptr<SpillContext>& spill_context) {
861
1.01k
    DCHECK(spill_context);
862
1.01k
    if (is_finalized()) {
863
0
        spill_context->on_task_finished();
864
0
        VLOG_DEBUG << "Query: " << print_id(_state->query_id()) << ", task: " << ((void*)this)
865
0
                   << " finalized";
866
0
        return Status::OK();
867
0
    }
868
869
1.01k
    const auto revocable_size = _sink->revocable_mem_size(_state);
870
1.01k
    if (revocable_size >= SpillStream::MIN_SPILL_WRITE_BATCH_MEM) {
871
1.01k
        auto revokable_task = std::make_shared<RevokableTask>(shared_from_this(), spill_context);
872
1.01k
        RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(revokable_task));
873
1.01k
    } else {
874
0
        spill_context->on_task_finished();
875
0
        LOG(INFO) << "Query: " << print_id(_state->query_id()) << ", task: " << ((void*)this)
876
0
                  << " has not enough data to revoke: " << revocable_size;
877
0
    }
878
1.01k
    return Status::OK();
879
1.01k
}
880
881
5.73M
Status PipelineTask::wake_up(Dependency* dep, std::unique_lock<std::mutex>& /* dep_lock */) {
882
    // call by dependency
883
5.73M
    DCHECK_EQ(_blocked_dep, dep) << "dep : " << dep->debug_string(0) << "task: " << debug_string();
884
5.73M
    _blocked_dep = nullptr;
885
5.73M
    auto holder = std::dynamic_pointer_cast<PipelineTask>(shared_from_this());
886
5.73M
    RETURN_IF_ERROR(_state_transition(PipelineTask::State::RUNNABLE));
887
5.73M
    if (auto f = _fragment_context.lock(); f) {
888
5.73M
        RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(holder));
889
5.73M
    }
890
5.73M
    return Status::OK();
891
5.73M
}
892
893
18.3M
Status PipelineTask::_state_transition(State new_state) {
894
18.3M
    if (_exec_state != new_state) {
895
18.3M
        _state_change_watcher.reset();
896
18.3M
        _state_change_watcher.start();
897
18.3M
    }
898
18.3M
    _task_profile->add_info_string("TaskState", _to_string(new_state));
899
18.3M
    _task_profile->add_info_string("BlockedByDependency", _blocked_dep ? _blocked_dep->name() : "");
900
18.3M
    if (!LEGAL_STATE_TRANSITION[(int)new_state].contains(_exec_state)) {
901
17
        return Status::InternalError(
902
17
                "Task state transition from {} to {} is not allowed! Task info: {}",
903
17
                _to_string(_exec_state), _to_string(new_state), debug_string());
904
17
    }
905
18.3M
    _exec_state = new_state;
906
18.3M
    return Status::OK();
907
18.3M
}
908
909
#include "common/compile_check_end.h"
910
} // namespace doris