Coverage Report

Created: 2026-03-13 21:11

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
1.78M
          _query_id(fragment_context->get_query_id()),
73
#endif
74
1.78M
          _index(task_id),
75
1.78M
          _pipeline(pipeline),
76
1.78M
          _opened(false),
77
1.78M
          _state(state),
78
1.78M
          _fragment_context(fragment_context),
79
1.78M
          _parent_profile(parent_profile),
80
1.78M
          _operators(pipeline->operators()),
81
1.78M
          _source(_operators.front().get()),
82
1.78M
          _root(_operators.back().get()),
83
1.78M
          _sink(pipeline->sink_shared_pointer()),
84
1.78M
          _shared_state_map(std::move(shared_state_map)),
85
1.78M
          _task_idx(task_idx),
86
1.78M
          _memory_sufficient_dependency(state->get_query_ctx()->get_memory_sufficient_dependency()),
87
1.78M
          _pipeline_name(_pipeline->name()) {
88
1.78M
#ifndef BE_TEST
89
1.78M
    _query_mem_tracker = fragment_context->get_query_ctx()->query_mem_tracker();
90
1.78M
#endif
91
1.78M
    _execution_dependencies.push_back(state->get_query_ctx()->get_execution_dependency());
92
1.78M
    if (!_shared_state_map.contains(_sink->dests_id().front())) {
93
1.45M
        auto shared_state = _sink->create_shared_state();
94
1.45M
        if (shared_state) {
95
1.44M
            _sink_shared_state = shared_state;
96
1.44M
        }
97
1.45M
    }
98
1.78M
}
99
100
1.79M
PipelineTask::~PipelineTask() {
101
1.87M
    auto reset_member = [&]() {
102
1.87M
        _shared_state_map.clear();
103
1.87M
        _sink_shared_state.reset();
104
1.87M
        _op_shared_states.clear();
105
1.87M
        _sink.reset();
106
1.87M
        _operators.clear();
107
1.87M
        _block.reset();
108
1.87M
        _pipeline.reset();
109
1.87M
    };
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
1.79M
#ifndef BE_TEST
115
1.79M
    if (_query_mem_tracker) {
116
1.79M
        SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_query_mem_tracker);
117
1.79M
        reset_member();
118
1.79M
        return;
119
1.79M
    }
120
1.19k
#endif
121
1.19k
    reset_member();
122
1.19k
}
123
124
Status PipelineTask::prepare(const std::vector<TScanRangeParams>& scan_range, const int sender_id,
125
1.77M
                             const TDataSink& tsink) {
126
1.77M
    DCHECK(_sink);
127
1.77M
    _init_profile();
128
1.77M
    SCOPED_TIMER(_task_profile->total_time_counter());
129
1.77M
    SCOPED_CPU_TIMER(_task_cpu_timer);
130
1.77M
    SCOPED_TIMER(_prepare_timer);
131
1.77M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::prepare", {
132
1.77M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task prepare failed");
133
1.77M
        return status;
134
1.77M
    });
135
1.77M
    {
136
        // set sink local state
137
1.77M
        LocalSinkStateInfo info {_task_idx,         _task_profile.get(),
138
1.77M
                                 sender_id,         get_sink_shared_state().get(),
139
1.77M
                                 _shared_state_map, tsink};
140
1.77M
        RETURN_IF_ERROR(_sink->setup_local_state(_state, info));
141
1.77M
    }
142
143
1.77M
    _scan_ranges = scan_range;
144
1.77M
    auto* parent_profile = _state->get_sink_local_state()->operator_profile();
145
146
4.14M
    for (int op_idx = cast_set<int>(_operators.size() - 1); op_idx >= 0; op_idx--) {
147
2.36M
        auto& op = _operators[op_idx];
148
2.36M
        LocalStateInfo info {parent_profile, _scan_ranges, get_op_shared_state(op->operator_id()),
149
2.36M
                             _shared_state_map, _task_idx};
150
2.36M
        RETURN_IF_ERROR(op->setup_local_state(_state, info));
151
2.36M
        parent_profile = _state->get_local_state(op->operator_id())->operator_profile();
152
2.36M
    }
153
1.77M
    {
154
1.77M
        const auto& deps =
155
1.77M
                _state->get_local_state(_source->operator_id())->execution_dependencies();
156
1.77M
        std::unique_lock<std::mutex> lc(_dependency_lock);
157
1.77M
        std::copy(deps.begin(), deps.end(),
158
1.77M
                  std::inserter(_execution_dependencies, _execution_dependencies.end()));
159
1.77M
    }
160
1.78M
    if (auto fragment = _fragment_context.lock()) {
161
1.78M
        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
1.78M
    _block = doris::Block::create_unique();
169
1.78M
    return _state_transition(State::RUNNABLE);
170
1.77M
}
171
172
1.79M
Status PipelineTask::_extract_dependencies() {
173
1.79M
    std::vector<std::vector<Dependency*>> read_dependencies;
174
1.79M
    std::vector<Dependency*> write_dependencies;
175
1.79M
    std::vector<Dependency*> finish_dependencies;
176
1.79M
    read_dependencies.resize(_operators.size());
177
1.79M
    size_t i = 0;
178
2.37M
    for (auto& op : _operators) {
179
2.37M
        auto* local_state = _state->get_local_state(op->operator_id());
180
2.37M
        DCHECK(local_state);
181
2.37M
        read_dependencies[i] = local_state->dependencies();
182
2.37M
        auto* fin_dep = local_state->finishdependency();
183
2.37M
        if (fin_dep) {
184
8
            finish_dependencies.push_back(fin_dep);
185
8
        }
186
2.37M
        i++;
187
2.37M
    }
188
1.79M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::_extract_dependencies", {
189
1.79M
        Status status = Status::Error<INTERNAL_ERROR>(
190
1.79M
                "fault_inject pipeline_task _extract_dependencies failed");
191
1.79M
        return status;
192
1.79M
    });
193
1.79M
    {
194
1.79M
        auto* local_state = _state->get_sink_local_state();
195
1.79M
        write_dependencies = local_state->dependencies();
196
1.79M
        auto* fin_dep = local_state->finishdependency();
197
1.79M
        if (fin_dep) {
198
761k
            finish_dependencies.push_back(fin_dep);
199
761k
        }
200
1.79M
    }
201
1.79M
    {
202
1.79M
        std::unique_lock<std::mutex> lc(_dependency_lock);
203
1.79M
        read_dependencies.swap(_read_dependencies);
204
1.79M
        write_dependencies.swap(_write_dependencies);
205
1.79M
        finish_dependencies.swap(_finish_dependencies);
206
1.79M
    }
207
1.79M
    return Status::OK();
208
1.79M
}
209
210
1.10M
bool PipelineTask::inject_shared_state(std::shared_ptr<BasicSharedState> shared_state) {
211
1.10M
    if (!shared_state) {
212
638k
        return false;
213
638k
    }
214
    // Shared state is created by upstream task's sink operator and shared by source operator of
215
    // this task.
216
585k
    for (auto& op : _operators) {
217
585k
        if (shared_state->related_op_ids.contains(op->operator_id())) {
218
459k
            _op_shared_states.insert({op->operator_id(), shared_state});
219
459k
            return true;
220
459k
        }
221
585k
    }
222
    // Shared state is created by the first sink operator and shared by sink operator of this task.
223
    // For example, Set operations.
224
11.9k
    if (shared_state->related_op_ids.contains(_sink->dests_id().front())) {
225
11.9k
        DCHECK_EQ(_sink_shared_state, nullptr)
226
0
                << " Sink: " << _sink->get_name() << " dest id: " << _sink->dests_id().front();
227
11.9k
        _sink_shared_state = shared_state;
228
11.9k
        return true;
229
11.9k
    }
230
18.4E
    return false;
231
9.66k
}
232
233
1.78M
void PipelineTask::_init_profile() {
234
1.78M
    _task_profile = std::make_unique<RuntimeProfile>(fmt::format("PipelineTask(index={})", _index));
235
1.78M
    _parent_profile->add_child(_task_profile.get(), true, nullptr);
236
1.78M
    _task_cpu_timer = ADD_TIMER(_task_profile, "TaskCpuTime");
237
238
1.78M
    static const char* exec_time = "ExecuteTime";
239
1.78M
    _exec_timer = ADD_TIMER(_task_profile, exec_time);
240
1.78M
    _prepare_timer = ADD_CHILD_TIMER(_task_profile, "PrepareTime", exec_time);
241
1.78M
    _open_timer = ADD_CHILD_TIMER(_task_profile, "OpenTime", exec_time);
242
1.78M
    _get_block_timer = ADD_CHILD_TIMER(_task_profile, "GetBlockTime", exec_time);
243
1.78M
    _get_block_counter = ADD_COUNTER(_task_profile, "GetBlockCounter", TUnit::UNIT);
244
1.78M
    _sink_timer = ADD_CHILD_TIMER(_task_profile, "SinkTime", exec_time);
245
1.78M
    _close_timer = ADD_CHILD_TIMER(_task_profile, "CloseTime", exec_time);
246
247
1.78M
    _wait_worker_timer = ADD_TIMER_WITH_LEVEL(_task_profile, "WaitWorkerTime", 1);
248
249
1.78M
    _schedule_counts = ADD_COUNTER(_task_profile, "NumScheduleTimes", TUnit::UNIT);
250
1.78M
    _yield_counts = ADD_COUNTER(_task_profile, "NumYieldTimes", TUnit::UNIT);
251
1.78M
    _core_change_times = ADD_COUNTER(_task_profile, "CoreChangeTimes", TUnit::UNIT);
252
1.78M
    _memory_reserve_times = ADD_COUNTER(_task_profile, "MemoryReserveTimes", TUnit::UNIT);
253
1.78M
    _memory_reserve_failed_times =
254
1.78M
            ADD_COUNTER(_task_profile, "MemoryReserveFailedTimes", TUnit::UNIT);
255
1.78M
}
256
257
1.78M
void PipelineTask::_fresh_profile_counter() {
258
1.78M
    COUNTER_SET(_schedule_counts, (int64_t)_schedule_time);
259
1.78M
    COUNTER_SET(_wait_worker_timer, (int64_t)_wait_worker_watcher.elapsed_time());
260
1.78M
}
261
262
1.78M
Status PipelineTask::_open() {
263
1.78M
    SCOPED_TIMER(_task_profile->total_time_counter());
264
1.78M
    SCOPED_CPU_TIMER(_task_cpu_timer);
265
1.78M
    SCOPED_TIMER(_open_timer);
266
1.78M
    _dry_run = _sink->should_dry_run(_state);
267
2.38M
    for (auto& o : _operators) {
268
2.38M
        RETURN_IF_ERROR(_state->get_local_state(o->operator_id())->open(_state));
269
2.38M
    }
270
1.78M
    RETURN_IF_ERROR(_state->get_sink_local_state()->open(_state));
271
1.78M
    RETURN_IF_ERROR(_extract_dependencies());
272
1.78M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::open", {
273
1.78M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task open failed");
274
1.78M
        return status;
275
1.78M
    });
276
1.78M
    _opened = true;
277
1.78M
    return Status::OK();
278
1.78M
}
279
280
10.0M
Status PipelineTask::_prepare() {
281
10.0M
    SCOPED_TIMER(_task_profile->total_time_counter());
282
10.0M
    SCOPED_CPU_TIMER(_task_cpu_timer);
283
13.1M
    for (auto& o : _operators) {
284
13.1M
        RETURN_IF_ERROR(_state->get_local_state(o->operator_id())->prepare(_state));
285
13.1M
    }
286
10.0M
    RETURN_IF_ERROR(_state->get_sink_local_state()->prepare(_state));
287
10.0M
    return Status::OK();
288
10.0M
}
289
290
5.85M
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
5.85M
    return std::any_of(
296
5.85M
            _execution_dependencies.begin(), _execution_dependencies.end(),
297
7.20M
            [&](Dependency* dep) -> bool { return dep->is_blocked_by(shared_from_this()); });
298
5.85M
}
299
300
2.14M
bool PipelineTask::_is_pending_finish() {
301
    // Spilling may be in progress if eos is true.
302
2.14M
    return std::ranges::any_of(_finish_dependencies, [&](Dependency* dep) -> bool {
303
1.12M
        return dep->is_blocked_by(shared_from_this());
304
1.12M
    });
305
2.14M
}
306
307
6.23M
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
6.23M
    if (_state->enable_fuzzy_blockable_task()) {
314
40.5k
        if ((_schedule_time + _task_idx) % 2 == 0) {
315
23.8k
            return true;
316
23.8k
        }
317
40.5k
    }
318
319
6.20M
    return std::ranges::any_of(_operators,
320
8.23M
                               [&](OperatorPtr op) -> bool { return op->is_blockable(_state); }) ||
321
6.21M
           _sink->is_blockable(_state);
322
6.23M
}
323
324
36.4M
bool PipelineTask::_is_blocked() {
325
    // `_dry_run = true` means we do not need data from source operator.
326
36.4M
    if (!_dry_run) {
327
43.5M
        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
39.7M
            for (auto* dep : _read_dependencies[i]) {
330
39.7M
                if (dep->is_blocked_by(shared_from_this())) {
331
2.35M
                    return true;
332
2.35M
                }
333
39.7M
            }
334
            // If all dependencies are ready for this operator, we can execute this task if no datum is needed from upstream operators.
335
35.3M
            if (!_operators[i]->need_more_input_data(_state)) {
336
28.2M
                break;
337
28.2M
            }
338
35.3M
        }
339
36.4M
    }
340
34.1M
    return _memory_sufficient_dependency->is_blocked_by(shared_from_this()) ||
341
37.5M
           std::ranges::any_of(_write_dependencies, [&](Dependency* dep) -> bool {
342
37.5M
               return dep->is_blocked_by(shared_from_this());
343
37.5M
           });
344
36.4M
}
345
346
1.16M
void PipelineTask::terminate() {
347
    // We use a lock to assure all dependencies are not deconstructed here.
348
1.16M
    std::unique_lock<std::mutex> lc(_dependency_lock);
349
1.16M
    auto fragment = _fragment_context.lock();
350
1.16M
    if (!is_finalized() && fragment) {
351
39.2k
        try {
352
39.2k
            DCHECK(_wake_up_early || fragment->is_canceled());
353
39.2k
            std::ranges::for_each(_write_dependencies,
354
260k
                                  [&](Dependency* dep) { dep->set_always_ready(); });
355
39.2k
            std::ranges::for_each(_finish_dependencies,
356
39.2k
                                  [&](Dependency* dep) { dep->set_always_ready(); });
357
42.2k
            std::ranges::for_each(_read_dependencies, [&](std::vector<Dependency*>& deps) {
358
47.8k
                std::ranges::for_each(deps, [&](Dependency* dep) { dep->set_always_ready(); });
359
42.2k
            });
360
            // All `_execution_deps` will never be set blocking from ready. So we just set ready here.
361
39.2k
            std::ranges::for_each(_execution_dependencies,
362
52.3k
                                  [&](Dependency* dep) { dep->set_ready(); });
363
39.2k
            _memory_sufficient_dependency->set_ready();
364
39.2k
        } catch (const doris::Exception& e) {
365
0
            LOG(WARNING) << "Terminate failed: " << e.code() << ", " << e.to_string();
366
0
        }
367
39.2k
    }
368
1.16M
}
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
6.23M
Status PipelineTask::execute(bool* done) {
386
6.23M
    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
6.23M
    auto fragment_context = _fragment_context.lock();
396
6.23M
    if (!fragment_context) {
397
0
        return Status::InternalError("Fragment already finished! Query: {}", print_id(_query_id));
398
0
    }
399
6.23M
    int64_t time_spent = 0;
400
6.23M
    ThreadCpuStopWatch cpu_time_stop_watch;
401
6.23M
    cpu_time_stop_watch.start();
402
6.23M
    SCOPED_ATTACH_TASK(_state);
403
6.23M
    Defer running_defer {[&]() {
404
6.22M
        int64_t delta_cpu_time = cpu_time_stop_watch.elapsed_time();
405
6.22M
        _task_cpu_timer->update(delta_cpu_time);
406
6.22M
        fragment_context->get_query_ctx()->resource_ctx()->cpu_context()->update_cpu_cost_ms(
407
6.22M
                delta_cpu_time);
408
409
        // If task is woke up early, we should terminate all operators, and this task could be closed immediately.
410
6.22M
        if (_wake_up_early) {
411
6.52k
            terminate();
412
6.52k
            THROW_IF_ERROR(_root->terminate(_state));
413
6.52k
            THROW_IF_ERROR(_sink->terminate(_state));
414
6.52k
            _eos = true;
415
6.52k
            *done = true;
416
6.21M
        } else if (_eos && !_spilling &&
417
6.21M
                   (fragment_context->is_canceled() || !_is_pending_finish())) {
418
1.78M
            *done = true;
419
1.78M
        }
420
6.22M
    }};
421
6.23M
    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
6.23M
    if (_eos && !_spilling) {
425
363k
        return Status::OK();
426
363k
    }
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
5.87M
    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
5.87M
    SCOPED_TIMER(_task_profile->total_time_counter());
436
5.87M
    SCOPED_TIMER(_exec_timer);
437
438
5.87M
    if (!_wake_up_early) {
439
5.87M
        RETURN_IF_ERROR(_prepare());
440
5.87M
    }
441
5.87M
    DBUG_EXECUTE_IF("fault_inject::PipelineXTask::execute", {
442
5.87M
        Status status = Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task execute failed");
443
5.87M
        return status;
444
5.87M
    });
445
    // `_wake_up_early` must be after `_wait_to_start()`
446
5.87M
    if (_wait_to_start() || _wake_up_early) {
447
1.64M
        return Status::OK();
448
1.64M
    }
449
4.23M
    RETURN_IF_ERROR(_prepare());
450
451
    // The status must be runnable
452
4.23M
    if (!_opened && !fragment_context->is_canceled()) {
453
1.79M
        DBUG_EXECUTE_IF("PipelineTask::execute.open_sleep", {
454
1.79M
            auto required_pipeline_id =
455
1.79M
                    DebugPoints::instance()->get_debug_param_or_default<int32_t>(
456
1.79M
                            "PipelineTask::execute.open_sleep", "pipeline_id", -1);
457
1.79M
            auto required_task_id = DebugPoints::instance()->get_debug_param_or_default<int32_t>(
458
1.79M
                    "PipelineTask::execute.open_sleep", "task_id", -1);
459
1.79M
            if (required_pipeline_id == pipeline_id() && required_task_id == task_id()) {
460
1.79M
                LOG(WARNING) << "PipelineTask::execute.open_sleep sleep 5s";
461
1.79M
                sleep(5);
462
1.79M
            }
463
1.79M
        });
464
465
1.79M
        SCOPED_RAW_TIMER(&time_spent);
466
1.79M
        RETURN_IF_ERROR(_open());
467
1.79M
    }
468
469
36.4M
    while (!fragment_context->is_canceled()) {
470
36.4M
        SCOPED_RAW_TIMER(&time_spent);
471
36.4M
        Defer defer {[&]() {
472
            // If this run is pended by a spilling request, the block will be output in next run.
473
36.4M
            if (!_spilling) {
474
36.4M
                _block->clear_column_data(_root->row_desc().num_materialized_slots());
475
36.4M
            }
476
36.4M
        }};
477
        // `_wake_up_early` must be after `_is_blocked()`
478
36.4M
        if (_is_blocked() || _wake_up_early) {
479
2.37M
            return Status::OK();
480
2.37M
        }
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
34.1M
        if (fragment_context->is_canceled()) {
486
0
            break;
487
0
        }
488
489
34.1M
        if (time_spent > _exec_time_slice) {
490
56.3k
            COUNTER_UPDATE(_yield_counts, 1);
491
56.3k
            break;
492
56.3k
        }
493
34.0M
        auto* block = _block.get();
494
495
34.0M
        DBUG_EXECUTE_IF("fault_inject::PipelineXTask::executing", {
496
34.0M
            Status status =
497
34.0M
                    Status::Error<INTERNAL_ERROR>("fault_inject pipeline_task executing failed");
498
34.0M
            return status;
499
34.0M
        });
500
501
        // `_sink->is_finished(_state)` means sink operator should be finished
502
34.0M
        if (_sink->is_finished(_state)) {
503
24
            set_wake_up_early();
504
24
            return Status::OK();
505
24
        }
506
507
        // `_dry_run` means sink operator need no more data
508
34.0M
        _eos = _dry_run || _eos;
509
34.0M
        _spilling = false;
510
34.0M
        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
34.0M
        if (!_eos && _block->empty()) {
514
34.0M
            SCOPED_TIMER(_get_block_timer);
515
34.0M
            if (_state->low_memory_mode()) {
516
17.1k
                _sink->set_low_memory_mode(_state);
517
17.1k
                _root->set_low_memory_mode(_state);
518
17.1k
            }
519
34.0M
            DEFER_RELEASE_RESERVED();
520
34.0M
            _get_block_counter->update(1);
521
34.0M
            const auto reserve_size = _root->get_reserve_mem_size(_state);
522
34.0M
            _root->reset_reserve_mem_size(_state);
523
524
34.0M
            if (workload_group &&
525
34.0M
                _state->get_query_ctx()
526
33.1M
                        ->resource_ctx()
527
33.1M
                        ->task_controller()
528
33.1M
                        ->is_enable_reserve_memory() &&
529
34.0M
                reserve_size > 0) {
530
33.0M
                if (!_try_to_reserve_memory(reserve_size, _root)) {
531
2.70k
                    continue;
532
2.70k
                }
533
33.0M
            }
534
535
34.0M
            bool eos = false;
536
34.0M
            RETURN_IF_ERROR(_root->get_block_after_projects(_state, block, &eos));
537
34.0M
            RETURN_IF_ERROR(block->check_type_and_column());
538
34.0M
            _eos = eos;
539
34.0M
        }
540
541
34.0M
        if (!_block->empty() || _eos) {
542
2.41M
            SCOPED_TIMER(_sink_timer);
543
2.41M
            Status status = Status::OK();
544
2.41M
            DEFER_RELEASE_RESERVED();
545
2.41M
            if (_state->get_query_ctx()
546
2.41M
                        ->resource_ctx()
547
2.41M
                        ->task_controller()
548
2.41M
                        ->is_enable_reserve_memory() &&
549
2.41M
                workload_group && !(_wake_up_early || _dry_run)) {
550
2.38M
                const auto sink_reserve_size = _sink->get_reserve_mem_size(_state, _eos);
551
2.38M
                if (sink_reserve_size > 0 &&
552
2.38M
                    !_try_to_reserve_memory(sink_reserve_size, _sink.get())) {
553
941
                    continue;
554
941
                }
555
2.38M
            }
556
557
2.41M
            DBUG_EXECUTE_IF("PipelineTask::execute.sink_eos_sleep", {
558
2.41M
                auto required_pipeline_id =
559
2.41M
                        DebugPoints::instance()->get_debug_param_or_default<int32_t>(
560
2.41M
                                "PipelineTask::execute.sink_eos_sleep", "pipeline_id", -1);
561
2.41M
                auto required_task_id =
562
2.41M
                        DebugPoints::instance()->get_debug_param_or_default<int32_t>(
563
2.41M
                                "PipelineTask::execute.sink_eos_sleep", "task_id", -1);
564
2.41M
                if (required_pipeline_id == pipeline_id() && required_task_id == task_id()) {
565
2.41M
                    LOG(WARNING) << "PipelineTask::execute.sink_eos_sleep sleep 10s";
566
2.41M
                    sleep(10);
567
2.41M
                }
568
2.41M
            });
569
570
2.41M
            DBUG_EXECUTE_IF("PipelineTask::execute.terminate", {
571
2.41M
                if (_eos) {
572
2.41M
                    auto required_pipeline_id =
573
2.41M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
574
2.41M
                                    "PipelineTask::execute.terminate", "pipeline_id", -1);
575
2.41M
                    auto required_task_id =
576
2.41M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
577
2.41M
                                    "PipelineTask::execute.terminate", "task_id", -1);
578
2.41M
                    auto required_fragment_id =
579
2.41M
                            DebugPoints::instance()->get_debug_param_or_default<int32_t>(
580
2.41M
                                    "PipelineTask::execute.terminate", "fragment_id", -1);
581
2.41M
                    if (required_pipeline_id == pipeline_id() && required_task_id == task_id() &&
582
2.41M
                        fragment_context->get_fragment_id() == required_fragment_id) {
583
2.41M
                        _wake_up_early = true;
584
2.41M
                        terminate();
585
2.41M
                    } else if (required_pipeline_id == pipeline_id() &&
586
2.41M
                               fragment_context->get_fragment_id() == required_fragment_id) {
587
2.41M
                        LOG(WARNING) << "PipelineTask::execute.terminate sleep 5s";
588
2.41M
                        sleep(5);
589
2.41M
                    }
590
2.41M
                }
591
2.41M
            });
592
2.41M
            RETURN_IF_ERROR(block->check_type_and_column());
593
2.41M
            status = _sink->sink(_state, block, _eos);
594
595
2.41M
            if (_eos) {
596
1.79M
                if (_sink->reset_to_rerun(_state, _root)) {
597
1.87k
                    _eos = false;
598
1.79M
                } else {
599
1.79M
                    RETURN_IF_ERROR(close(Status::OK(), false));
600
1.79M
                }
601
1.79M
            }
602
603
2.41M
            if (status.is<ErrorCode::END_OF_FILE>()) {
604
10
                set_wake_up_early();
605
10
                return Status::OK();
606
2.41M
            } else if (!status) {
607
16
                return status;
608
16
            }
609
610
2.41M
            if (_eos) { // just return, the scheduler will do finish work
611
1.78M
                return Status::OK();
612
1.78M
            }
613
2.41M
        }
614
34.0M
    }
615
616
63.4k
    RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(shared_from_this()));
617
63.4k
    return Status::OK();
618
63.4k
}
619
620
1.74k
Status PipelineTask::do_revoke_memory(const std::shared_ptr<SpillContext>& spill_context) {
621
1.74k
    auto fragment_context = _fragment_context.lock();
622
1.74k
    if (!fragment_context) {
623
0
        return Status::InternalError("Fragment already finished! Query: {}", print_id(_query_id));
624
0
    }
625
626
1.74k
    SCOPED_ATTACH_TASK(_state);
627
1.74k
    ThreadCpuStopWatch cpu_time_stop_watch;
628
1.74k
    cpu_time_stop_watch.start();
629
1.74k
    Defer running_defer {[&]() {
630
1.74k
        int64_t delta_cpu_time = cpu_time_stop_watch.elapsed_time();
631
1.74k
        _task_cpu_timer->update(delta_cpu_time);
632
1.74k
        fragment_context->get_query_ctx()->resource_ctx()->cpu_context()->update_cpu_cost_ms(
633
1.74k
                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.74k
        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.74k
    }};
643
644
1.74k
    return _sink->revoke_memory(_state, spill_context);
645
1.74k
}
646
647
35.2M
bool PipelineTask::_try_to_reserve_memory(const size_t reserve_size, OperatorBase* op) {
648
35.2M
    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
35.2M
    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
35.2M
    COUNTER_UPDATE(_memory_reserve_times, 1);
658
35.2M
    auto sink_revocable_mem_size = _sink->revocable_mem_size(_state);
659
35.2M
    if (st.ok() && _state->enable_force_spill() && _sink->is_spillable() &&
660
35.2M
        sink_revocable_mem_size >= SpillStream::MIN_SPILL_WRITE_BATCH_MEM) {
661
1.74k
        st = Status(ErrorCode::QUERY_MEMORY_EXCEEDED, "Force Spill");
662
1.74k
    }
663
35.2M
    if (!st.ok()) {
664
3.64k
        COUNTER_UPDATE(_memory_reserve_failed_times, 1);
665
3.64k
        auto debug_msg = fmt::format(
666
3.64k
                "Query: {} , try to reserve: {}, operator name: {}, operator "
667
3.64k
                "id: {}, task id: {}, root revocable mem size: {}, sink revocable mem"
668
3.64k
                "size: {}, failed: {}",
669
3.64k
                print_id(_query_id), PrettyPrinter::print_bytes(reserve_size), op->get_name(),
670
3.64k
                op->node_id(), _state->task_id(),
671
3.64k
                PrettyPrinter::print_bytes(op->revocable_mem_size(_state)),
672
3.64k
                PrettyPrinter::print_bytes(sink_revocable_mem_size), st.to_string());
673
        // PROCESS_MEMORY_EXCEEDED error msg already contains process_mem_log_str
674
3.64k
        if (!st.is<ErrorCode::PROCESS_MEMORY_EXCEEDED>()) {
675
3.64k
            debug_msg +=
676
3.64k
                    fmt::format(", debug info: {}", GlobalMemoryArbitrator::process_mem_log_str());
677
3.64k
        }
678
        // If sink has enough revocable memory, trigger revoke memory
679
3.64k
        LOG(INFO) << fmt::format(
680
3.64k
                "Query: {} sink: {}, node id: {}, task id: "
681
3.64k
                "{}, revocable mem size: {}",
682
3.64k
                print_id(_query_id), _sink->get_name(), _sink->node_id(), _state->task_id(),
683
3.64k
                PrettyPrinter::print_bytes(sink_revocable_mem_size));
684
3.64k
        ExecEnv::GetInstance()->workload_group_mgr()->add_paused_query(
685
3.64k
                _state->get_query_ctx()->resource_ctx()->shared_from_this(), reserve_size, st);
686
3.64k
        _spilling = true;
687
3.64k
        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
3.64k
    }
711
35.2M
    return true;
712
35.2M
}
713
714
1.49M
void PipelineTask::stop_if_finished() {
715
1.49M
    auto fragment = _fragment_context.lock();
716
1.49M
    if (!fragment) {
717
0
        return;
718
0
    }
719
1.49M
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(fragment->get_query_ctx()->query_mem_tracker());
720
1.49M
    if (auto sink = _sink) {
721
1.22M
        if (sink->is_finished(_state)) {
722
3.23k
            set_wake_up_early();
723
3.23k
            terminate();
724
3.23k
        }
725
1.22M
    }
726
1.49M
}
727
728
1.78M
Status PipelineTask::finalize() {
729
1.78M
    auto fragment = _fragment_context.lock();
730
1.78M
    if (!fragment) {
731
0
        return Status::OK();
732
0
    }
733
1.78M
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(fragment->get_query_ctx()->query_mem_tracker());
734
1.78M
    RETURN_IF_ERROR(_state_transition(State::FINALIZED));
735
1.78M
    std::unique_lock<std::mutex> lc(_dependency_lock);
736
1.78M
    _sink_shared_state.reset();
737
1.78M
    _op_shared_states.clear();
738
1.78M
    _shared_state_map.clear();
739
1.78M
    _block.reset();
740
1.78M
    _operators.clear();
741
1.78M
    _sink.reset();
742
1.78M
    _pipeline.reset();
743
1.78M
    return Status::OK();
744
1.78M
}
745
746
3.57M
Status PipelineTask::close(Status exec_status, bool close_sink) {
747
3.57M
    int64_t close_ns = 0;
748
3.57M
    Status s;
749
3.57M
    {
750
3.57M
        SCOPED_RAW_TIMER(&close_ns);
751
3.57M
        if (close_sink) {
752
1.79M
            s = _sink->close(_state, exec_status);
753
1.79M
        }
754
4.77M
        for (auto& op : _operators) {
755
4.77M
            auto tem = op->close(_state);
756
4.77M
            if (!tem.ok() && s.ok()) {
757
6
                s = std::move(tem);
758
6
            }
759
4.77M
        }
760
3.57M
    }
761
3.58M
    if (_opened) {
762
3.58M
        COUNTER_UPDATE(_close_timer, close_ns);
763
3.58M
        COUNTER_UPDATE(_task_profile->total_time_counter(), close_ns);
764
3.58M
    }
765
766
3.57M
    if (close_sink && _opened) {
767
1.79M
        _task_profile->add_info_string("WakeUpEarly", std::to_string(_wake_up_early.load()));
768
1.79M
        _fresh_profile_counter();
769
1.79M
    }
770
771
3.57M
    if (close_sink) {
772
1.79M
        RETURN_IF_ERROR(_state_transition(State::FINISHED));
773
1.79M
    }
774
3.57M
    return s;
775
3.57M
}
776
777
58.9k
std::string PipelineTask::debug_string() {
778
58.9k
    fmt::memory_buffer debug_string_buffer;
779
780
58.9k
    fmt::format_to(debug_string_buffer, "QueryId: {}\n", print_id(_query_id));
781
58.9k
    fmt::format_to(debug_string_buffer, "InstanceId: {}\n",
782
58.9k
                   print_id(_state->fragment_instance_id()));
783
784
58.9k
    fmt::format_to(debug_string_buffer,
785
58.9k
                   "PipelineTask[id = {}, open = {}, eos = {}, state = {}, dry run = "
786
58.9k
                   "{}, _wake_up_early = {}, _wake_up_by = {}, time elapsed since last state "
787
58.9k
                   "changing = {}s, spilling = {}, is running = {}]",
788
58.9k
                   _index, _opened, _eos, _to_string(_exec_state), _dry_run, _wake_up_early.load(),
789
58.9k
                   _wake_by, _state_change_watcher.elapsed_time() / NANOS_PER_SEC, _spilling,
790
58.9k
                   is_running());
791
58.9k
    std::unique_lock<std::mutex> lc(_dependency_lock);
792
58.9k
    auto* cur_blocked_dep = _blocked_dep;
793
58.9k
    auto fragment = _fragment_context.lock();
794
58.9k
    if (is_finalized() || !fragment) {
795
2.91k
        fmt::format_to(debug_string_buffer, " pipeline name = {}", _pipeline_name);
796
2.91k
        return fmt::to_string(debug_string_buffer);
797
2.91k
    }
798
56.0k
    auto elapsed = fragment->elapsed_time() / NANOS_PER_SEC;
799
56.0k
    fmt::format_to(debug_string_buffer, " elapse time = {}s, block dependency = [{}]\n", elapsed,
800
56.0k
                   cur_blocked_dep && !is_finalized() ? cur_blocked_dep->debug_string() : "NULL");
801
802
56.0k
    if (_state && _state->local_runtime_filter_mgr()) {
803
1.01k
        fmt::format_to(debug_string_buffer, "local_runtime_filter_mgr: [{}]\n",
804
1.01k
                       _state->local_runtime_filter_mgr()->debug_string());
805
1.01k
    }
806
807
56.0k
    fmt::format_to(debug_string_buffer, "operators: ");
808
112k
    for (size_t i = 0; i < _operators.size(); i++) {
809
56.0k
        fmt::format_to(debug_string_buffer, "\n{}",
810
56.0k
                       _opened && !is_finalized()
811
56.0k
                               ? _operators[i]->debug_string(_state, cast_set<int>(i))
812
56.0k
                               : _operators[i]->debug_string(cast_set<int>(i)));
813
56.0k
    }
814
56.0k
    fmt::format_to(debug_string_buffer, "\n{}\n",
815
56.0k
                   _opened && !is_finalized()
816
56.0k
                           ? _sink->debug_string(_state, cast_set<int>(_operators.size()))
817
56.0k
                           : _sink->debug_string(cast_set<int>(_operators.size())));
818
819
56.0k
    fmt::format_to(debug_string_buffer, "\nRead Dependency Information: \n");
820
821
56.0k
    size_t i = 0;
822
111k
    for (; i < _read_dependencies.size(); i++) {
823
111k
        for (size_t j = 0; j < _read_dependencies[i].size(); j++) {
824
55.7k
            fmt::format_to(debug_string_buffer, "{}. {}\n", i,
825
55.7k
                           _read_dependencies[i][j]->debug_string(cast_set<int>(i) + 1));
826
55.7k
        }
827
55.7k
    }
828
829
56.0k
    fmt::format_to(debug_string_buffer, "{}. {}\n", i,
830
56.0k
                   _memory_sufficient_dependency->debug_string(cast_set<int>(i++)));
831
832
56.0k
    fmt::format_to(debug_string_buffer, "\nWrite Dependency Information: \n");
833
111k
    for (size_t j = 0; j < _write_dependencies.size(); j++, i++) {
834
55.7k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
835
55.7k
                       _write_dependencies[j]->debug_string(cast_set<int>(j) + 1));
836
55.7k
    }
837
838
56.0k
    fmt::format_to(debug_string_buffer, "\nExecution Dependency Information: \n");
839
167k
    for (size_t j = 0; j < _execution_dependencies.size(); j++, i++) {
840
111k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
841
111k
                       _execution_dependencies[j]->debug_string(cast_set<int>(i) + 1));
842
111k
    }
843
844
56.0k
    fmt::format_to(debug_string_buffer, "Finish Dependency Information: \n");
845
166k
    for (size_t j = 0; j < _finish_dependencies.size(); j++, i++) {
846
110k
        fmt::format_to(debug_string_buffer, "{}. {}\n", i,
847
110k
                       _finish_dependencies[j]->debug_string(cast_set<int>(i) + 1));
848
110k
    }
849
56.0k
    return fmt::to_string(debug_string_buffer);
850
58.9k
}
851
852
62.5k
size_t PipelineTask::get_revocable_size() const {
853
62.5k
    if (!_opened || is_finalized() || _running || (_eos && !_spilling)) {
854
10.9k
        return 0;
855
10.9k
    }
856
857
51.6k
    return _sink->revocable_mem_size(_state);
858
62.5k
}
859
860
1.74k
Status PipelineTask::revoke_memory(const std::shared_ptr<SpillContext>& spill_context) {
861
1.74k
    DCHECK(spill_context);
862
1.74k
    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.74k
    const auto revocable_size = _sink->revocable_mem_size(_state);
870
1.74k
    if (revocable_size >= SpillStream::MIN_SPILL_WRITE_BATCH_MEM) {
871
1.74k
        auto revokable_task = std::make_shared<RevokableTask>(shared_from_this(), spill_context);
872
1.74k
        RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(revokable_task));
873
1.74k
    } 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.74k
    return Status::OK();
879
1.74k
}
880
881
4.38M
Status PipelineTask::wake_up(Dependency* dep, std::unique_lock<std::mutex>& /* dep_lock */) {
882
    // call by dependency
883
4.38M
    DCHECK_EQ(_blocked_dep, dep) << "dep : " << dep->debug_string(0) << "task: " << debug_string();
884
4.38M
    _blocked_dep = nullptr;
885
4.38M
    auto holder = std::dynamic_pointer_cast<PipelineTask>(shared_from_this());
886
4.38M
    RETURN_IF_ERROR(_state_transition(PipelineTask::State::RUNNABLE));
887
4.38M
    if (auto f = _fragment_context.lock(); f) {
888
4.38M
        RETURN_IF_ERROR(_state->get_query_ctx()->get_pipe_exec_scheduler()->submit(holder));
889
4.38M
    }
890
4.38M
    return Status::OK();
891
4.38M
}
892
893
14.0M
Status PipelineTask::_state_transition(State new_state) {
894
14.0M
    if (_exec_state != new_state) {
895
14.0M
        _state_change_watcher.reset();
896
14.0M
        _state_change_watcher.start();
897
14.0M
    }
898
14.0M
    _task_profile->add_info_string("TaskState", _to_string(new_state));
899
14.0M
    _task_profile->add_info_string("BlockedByDependency", _blocked_dep ? _blocked_dep->name() : "");
900
14.0M
    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
14.0M
    _exec_state = new_state;
906
14.0M
    return Status::OK();
907
14.0M
}
908
909
#include "common/compile_check_end.h"
910
} // namespace doris