Coverage Report

Created: 2026-08-03 05:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/service/http/action/http_stream.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 "service/http/action/http_stream.h"
19
20
#include <algorithm>
21
#include <cstddef>
22
#include <future>
23
#include <sstream>
24
25
// use string iequal
26
#include <event2/buffer.h>
27
#include <event2/bufferevent.h>
28
#include <event2/http.h>
29
#include <gen_cpp/FrontendService.h>
30
#include <gen_cpp/FrontendService_types.h>
31
#include <gen_cpp/HeartbeatService_types.h>
32
#include <rapidjson/prettywriter.h>
33
#include <thrift/protocol/TDebugProtocol.h>
34
35
#include "cloud/config.h"
36
#include "common/config.h"
37
#include "common/logging.h"
38
#include "common/metrics/doris_metrics.h"
39
#include "common/metrics/metrics.h"
40
#include "common/status.h"
41
#include "common/utils.h"
42
#include "io/fs/stream_load_pipe.h"
43
#include "load/group_commit/group_commit_mgr.h"
44
#include "load/load_path_mgr.h"
45
#include "load/stream_load/new_load_stream_mgr.h"
46
#include "load/stream_load/stream_load_context.h"
47
#include "load/stream_load/stream_load_executor.h"
48
#include "load/stream_load/stream_load_recorder.h"
49
#include "runtime/exec_env.h"
50
#include "runtime/fragment_mgr.h"
51
#include "service/http/http_channel.h"
52
#include "service/http/http_common.h"
53
#include "service/http/http_headers.h"
54
#include "service/http/http_request.h"
55
#include "service/http/utils.h"
56
#include "storage/storage_engine.h"
57
#include "util/byte_buffer.h"
58
#include "util/client_cache.h"
59
#include "util/load_util.h"
60
#include "util/string_util.h"
61
#include "util/thrift_rpc_helper.h"
62
#include "util/time.h"
63
#include "util/uid_util.h"
64
65
namespace doris {
66
using namespace ErrorCode;
67
68
namespace {
69
70
constexpr size_t MEBIBYTE = 1024 * 1024;
71
72
10
bool is_compressed_file_scan(const TPipelineFragmentParams& params) {
73
10
    if (!params.__isset.file_scan_params) {
74
0
        return false;
75
0
    }
76
10
    return std::ranges::any_of(params.file_scan_params, [](const auto& file_scan_param) {
77
10
        const auto& file_scan_params = file_scan_param.second;
78
10
        TFileCompressType::type compress_type = file_scan_params.__isset.compress_type
79
10
                                                        ? file_scan_params.compress_type
80
10
                                                        : TFileCompressType::UNKNOWN;
81
10
        TFileFormatType::type format_type = file_scan_params.__isset.format_type
82
10
                                                    ? file_scan_params.format_type
83
10
                                                    : TFileFormatType::FORMAT_UNKNOWN;
84
10
        return LoadUtil::is_compressed_load(compress_type, format_type);
85
10
    });
86
10
}
87
88
} // namespace
89
90
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(http_stream_requests_total, MetricUnit::REQUESTS);
91
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(http_stream_duration_ms, MetricUnit::MILLISECONDS);
92
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(http_stream_current_processing, MetricUnit::REQUESTS);
93
94
HttpStreamAction::HttpStreamAction(ExecEnv* exec_env)
95
10
        : HttpHandlerWithAuth(exec_env, TPrivilegeHier::GLOBAL, TPrivilegeType::LOAD) {
96
    // Use LOAD privilege type: requires LOAD permission
97
    // Note: _exec_env is set by parent class HttpHandlerWithAuth
98
10
    _http_stream_entity =
99
10
            DorisMetrics::instance()->metric_registry()->register_entity("http_stream");
100
10
    INT_COUNTER_METRIC_REGISTER(_http_stream_entity, http_stream_requests_total);
101
10
    INT_COUNTER_METRIC_REGISTER(_http_stream_entity, http_stream_duration_ms);
102
10
    INT_GAUGE_METRIC_REGISTER(_http_stream_entity, http_stream_current_processing);
103
10
}
104
105
6
HttpStreamAction::~HttpStreamAction() {
106
6
    DorisMetrics::instance()->metric_registry()->deregister_entity(_http_stream_entity);
107
6
}
108
109
135
void HttpStreamAction::handle(HttpRequest* req) {
110
135
    std::shared_ptr<StreamLoadContext> ctx =
111
135
            std::static_pointer_cast<StreamLoadContext>(req->handler_ctx());
112
135
    if (ctx == nullptr) {
113
0
        return;
114
0
    }
115
116
    // status already set to fail
117
135
    if (ctx->status.ok()) {
118
114
        ctx->status = _handle(req, ctx);
119
114
        if (!ctx->status.ok() && !ctx->status.is<PUBLISH_TIMEOUT>()) {
120
3
            LOG(WARNING) << "handle streaming load failed, id=" << ctx->id
121
3
                         << ", errmsg=" << ctx->status;
122
3
        }
123
114
    }
124
135
    ctx->load_cost_millis = UnixMillis() - ctx->start_millis;
125
126
135
    if (!ctx->status.ok() && !ctx->status.is<PUBLISH_TIMEOUT>()) {
127
24
        if (ctx->body_sink != nullptr) {
128
24
            ctx->body_sink->cancel(ctx->status.to_string());
129
24
        }
130
24
    }
131
132
135
    if (!ctx->status.ok()) {
133
24
        auto str = std::string(ctx->to_json());
134
        // add new line at end
135
24
        str = str + '\n';
136
24
        HttpChannel::send_reply(req, str);
137
24
        return;
138
24
    }
139
111
    auto str = std::string(ctx->to_json());
140
    // add new line at end
141
111
    str = str + '\n';
142
111
    HttpChannel::send_reply(req, str);
143
111
    if (config::enable_stream_load_record || config::enable_stream_load_record_to_audit_log_table) {
144
111
        if (req->header(HTTP_SKIP_RECORD_TO_AUDIT_LOG_TABLE).empty()) {
145
111
            str = ctx->prepare_stream_load_record(str);
146
111
            _save_stream_load_record(ctx, str);
147
111
        }
148
111
    }
149
    // update statistics
150
111
    http_stream_requests_total->increment(1);
151
111
    http_stream_duration_ms->increment(ctx->load_cost_millis);
152
111
}
153
154
114
Status HttpStreamAction::_handle(HttpRequest* http_req, std::shared_ptr<StreamLoadContext> ctx) {
155
114
    if (ctx->body_bytes > 0 && ctx->receive_bytes != ctx->body_bytes) {
156
0
        LOG(WARNING) << "recevie body don't equal with body bytes, body_bytes=" << ctx->body_bytes
157
0
                     << ", receive_bytes=" << ctx->receive_bytes << ", id=" << ctx->id;
158
0
        return Status::Error<ErrorCode::NETWORK_ERROR>("receive body don't equal with body bytes");
159
0
    }
160
114
    RETURN_IF_ERROR(ctx->body_sink->finish());
161
162
    // wait stream load finish
163
114
    RETURN_IF_ERROR(ctx->load_status_future.get());
164
165
111
    if (ctx->group_commit) {
166
13
        LOG(INFO) << "skip commit because this is group commit, pipe_id=" << ctx->id.to_string();
167
13
        return Status::OK();
168
13
    }
169
170
98
    if (ctx->two_phase_commit) {
171
1
        int64_t pre_commit_start_time = MonotonicNanos();
172
1
        RETURN_IF_ERROR(_exec_env->stream_load_executor()->pre_commit_txn(ctx.get()));
173
1
        ctx->pre_commit_txn_cost_nanos = MonotonicNanos() - pre_commit_start_time;
174
97
    } else {
175
        // If put file success we need commit this load
176
97
        int64_t commit_and_publish_start_time = MonotonicNanos();
177
97
        RETURN_IF_ERROR(_exec_env->stream_load_executor()->commit_txn(ctx.get()));
178
97
        ctx->commit_and_publish_txn_cost_nanos = MonotonicNanos() - commit_and_publish_start_time;
179
97
    }
180
98
    return Status::OK();
181
98
}
182
183
135
int HttpStreamAction::on_header(HttpRequest* req) {
184
    // Call parent's auth check first
185
135
    int ret = HttpHandlerWithAuth::on_header(req);
186
135
    if (ret != 0) {
187
0
        return ret; // Auth failed, return error
188
0
    }
189
190
135
    http_stream_current_processing->increment(1);
191
192
135
    std::shared_ptr<StreamLoadContext> ctx = std::make_shared<StreamLoadContext>(_exec_env);
193
135
    req->set_handler_ctx(ctx);
194
195
135
    ctx->load_type = TLoadType::MANUL_LOAD;
196
135
    ctx->load_src_type = TLoadSourceType::RAW;
197
135
    ctx->two_phase_commit = req->header(HTTP_TWO_PHASE_COMMIT) == "true";
198
135
    Status st = _handle_group_commit(req, ctx);
199
200
135
    LOG(INFO) << "new income streaming load request." << ctx->brief()
201
135
              << " sql : " << req->header(HTTP_SQL) << ", group_commit=" << ctx->group_commit;
202
135
    if (st.ok()) {
203
135
        st = _on_header(req, ctx);
204
135
    }
205
135
    if (!st.ok()) {
206
0
        ctx->status = std::move(st);
207
0
        if (ctx->body_sink != nullptr) {
208
0
            ctx->body_sink->cancel(ctx->status.to_string());
209
0
        }
210
0
        auto str = ctx->to_json();
211
        // add new line at end
212
0
        str = str + '\n';
213
0
        HttpChannel::send_reply(req, str);
214
0
        if (config::enable_stream_load_record ||
215
0
            config::enable_stream_load_record_to_audit_log_table) {
216
0
            if (req->header(HTTP_SKIP_RECORD_TO_AUDIT_LOG_TABLE).empty()) {
217
0
                str = ctx->prepare_stream_load_record(str);
218
0
                _save_stream_load_record(ctx, str);
219
0
            }
220
0
        }
221
0
        return -1;
222
0
    }
223
135
    return 0;
224
135
}
225
226
136
Status HttpStreamAction::_on_header(HttpRequest* http_req, std::shared_ptr<StreamLoadContext> ctx) {
227
    // auth information
228
136
    if (!parse_basic_auth(*http_req, &ctx->auth)) {
229
0
        LOG(WARNING) << "parse basic authorization failed." << ctx->brief();
230
0
        return Status::NotAuthorized("no valid Basic authorization");
231
0
    }
232
233
    // TODO(zs) : need Need to request an FE to obtain information such as format
234
    // check content length
235
136
    ctx->body_bytes = 0;
236
136
    const auto csv_max_body_mb = config::streaming_load_max_mb;
237
136
    size_t csv_max_body_bytes = csv_max_body_mb * MEBIBYTE;
238
136
    if (!http_req->header(HttpHeaders::CONTENT_LENGTH).empty()) {
239
133
        try {
240
133
            ctx->body_bytes = std::stol(http_req->header(HttpHeaders::CONTENT_LENGTH));
241
133
        } catch (const std::exception& e) {
242
0
            return Status::InvalidArgument("invalid HTTP header CONTENT_LENGTH={}: {}",
243
0
                                           http_req->header(HttpHeaders::CONTENT_LENGTH), e.what());
244
0
        }
245
        // csv max body size
246
133
        if (ctx->body_bytes > csv_max_body_bytes) {
247
1
            LOG(WARNING) << "body exceed max size." << ctx->brief();
248
1
            return Status::Error<ErrorCode::EXCEEDED_LIMIT>(
249
1
                    "body size {} bytes ({:.2f} MiB) exceeds the limit of {} bytes ({} MiB) set "
250
1
                    "by BE config `streaming_load_max_mb`. Increase it if you are sure this load "
251
1
                    "is reasonable",
252
1
                    ctx->body_bytes, static_cast<double>(ctx->body_bytes) / MEBIBYTE,
253
1
                    csv_max_body_bytes, csv_max_body_mb);
254
1
        }
255
133
    }
256
257
135
    auto pipe = std::make_shared<io::StreamLoadPipe>(
258
135
            io::kMaxPipeBufferedBytes /* max_buffered_bytes */, 64 * 1024 /* min_chunk_size */,
259
135
            ctx->body_bytes /* total_length */);
260
135
    ctx->body_sink = pipe;
261
135
    ctx->pipe = pipe;
262
263
135
    RETURN_IF_ERROR(_exec_env->new_load_stream_mgr()->put(ctx->id, ctx));
264
265
    // Here, transactions are set from fe's NativeInsertStmt.
266
    // TODO(zs) : How to support two_phase_commit
267
268
135
    return Status::OK();
269
135
}
270
271
9.67k
void HttpStreamAction::on_chunk_data(HttpRequest* req) {
272
9.67k
    std::shared_ptr<StreamLoadContext> ctx =
273
9.67k
            std::static_pointer_cast<StreamLoadContext>(req->handler_ctx());
274
9.67k
    if (ctx == nullptr || !ctx->status.ok()) {
275
8
        return;
276
8
    }
277
9.67k
    if (!req->header(HTTP_WAL_ID_KY).empty()) {
278
0
        ctx->wal_id = std::stoll(req->header(HTTP_WAL_ID_KY));
279
0
    }
280
9.67k
    struct evhttp_request* ev_req = req->get_evhttp_request();
281
9.67k
    auto evbuf = evhttp_request_get_input_buffer(ev_req);
282
283
    // In HttpStreamAction::on_chunk_data
284
    //      -> process_put
285
    //      -> StreamLoadExecutor::execute_plan_fragment
286
    //      -> exec_plan_fragment
287
    // , SCOPED_ATTACH_TASK will be called.
288
9.67k
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(ExecEnv::GetInstance()->stream_load_pipe_tracker());
289
290
9.67k
    int64_t start_read_data_time = MonotonicNanos();
291
9.67k
    Status st = ctx->allocate_schema_buffer();
292
9.67k
    if (!st.ok()) {
293
0
        ctx->status = st;
294
0
        return;
295
0
    }
296
19.3k
    while (evbuffer_get_length(evbuf) > 0) {
297
9.67k
        ByteBufferPtr bb;
298
9.67k
        st = ByteBuffer::allocate(128 * 1024, &bb);
299
9.67k
        if (!st.ok()) {
300
0
            ctx->status = st;
301
0
            return;
302
0
        }
303
9.67k
        auto remove_bytes = evbuffer_remove(evbuf, bb->ptr, bb->capacity);
304
9.67k
        bb->pos = remove_bytes;
305
9.67k
        bb->flip();
306
9.67k
        st = ctx->body_sink->append(bb);
307
        // schema_buffer stores 1M of data for parsing column information
308
        // need to determine whether to cache for the first time
309
9.67k
        if (ctx->is_read_schema) {
310
135
            if (ctx->schema_buffer()->pos + remove_bytes < config::stream_tvf_buffer_size) {
311
135
                ctx->schema_buffer()->put_bytes(bb->ptr, remove_bytes);
312
135
            } else {
313
0
                LOG(INFO) << "use a portion of data to request fe to obtain column information";
314
0
                ctx->is_read_schema = false;
315
0
                ctx->status = process_put(req, ctx);
316
0
            }
317
135
        }
318
9.67k
        if (!st.ok()) {
319
0
            LOG(WARNING) << "append body content failed. errmsg=" << st << ", " << ctx->brief();
320
0
            ctx->status = st;
321
0
            return;
322
0
        }
323
9.67k
        ctx->receive_bytes += remove_bytes;
324
9.67k
    }
325
    // after all the data has been read and it has not reached 1M, it will execute here
326
9.67k
    if (ctx->is_read_schema) {
327
135
        LOG(INFO) << "after all the data has been read and it has not reached 1M, it will execute "
328
135
                  << "here";
329
135
        ctx->is_read_schema = false;
330
135
        ctx->status = process_put(req, ctx);
331
135
    }
332
9.67k
    ctx->read_data_cost_nanos += (MonotonicNanos() - start_read_data_time);
333
9.67k
}
334
335
135
void HttpStreamAction::free_handler_ctx(std::shared_ptr<void> param) {
336
135
    std::shared_ptr<StreamLoadContext> ctx = std::static_pointer_cast<StreamLoadContext>(param);
337
135
    if (ctx == nullptr) {
338
0
        return;
339
0
    }
340
    // sender is gone, make receiver know it
341
135
    if (ctx->body_sink != nullptr) {
342
135
        ctx->body_sink->cancel("sender is gone");
343
135
    }
344
    // remove stream load context from stream load manager and the resource will be released
345
135
    ctx->exec_env()->new_load_stream_mgr()->remove(ctx->id);
346
135
    http_stream_current_processing->increment(-1);
347
135
}
348
349
Status HttpStreamAction::process_put(HttpRequest* http_req,
350
135
                                     std::shared_ptr<StreamLoadContext> ctx) {
351
135
    TStreamLoadPutRequest request;
352
135
    if (http_req != nullptr) {
353
135
        request.__set_load_sql(http_req->header(HTTP_SQL));
354
135
        if (!http_req->header(HTTP_MEMTABLE_ON_SINKNODE).empty()) {
355
0
            bool value = iequal(http_req->header(HTTP_MEMTABLE_ON_SINKNODE), "true");
356
0
            request.__set_memtable_on_sink_node(value);
357
0
        }
358
135
    } else {
359
0
        request.__set_token(ctx->auth.token);
360
0
        request.__set_load_sql(ctx->sql_str);
361
0
        ctx->auth.token = "";
362
0
    }
363
135
    set_request_auth(&request, ctx->auth);
364
135
    request.__set_loadId(ctx->id.to_thrift());
365
135
    request.__set_label(ctx->label);
366
135
    if (ctx->group_commit) {
367
14
        if (!http_req->header(HTTP_GROUP_COMMIT).empty()) {
368
14
            request.__set_group_commit_mode(http_req->header(HTTP_GROUP_COMMIT));
369
14
        } else {
370
            // used for wait_internal_group_commit_finish
371
0
            request.__set_group_commit_mode("sync_mode");
372
0
        }
373
14
    }
374
135
    if (_exec_env->cluster_info()->backend_id != 0) {
375
135
        request.__set_backend_id(_exec_env->cluster_info()->backend_id);
376
135
    } else {
377
0
        LOG(WARNING) << "_exec_env->cluster_info not set backend_id";
378
0
    }
379
135
    if (ctx->wal_id > 0) {
380
0
        request.__set_partial_update(false);
381
0
    }
382
383
    // plan this load
384
135
    TNetworkAddress master_addr = _exec_env->cluster_info()->master_fe_addr;
385
135
    int64_t stream_load_put_start_time = MonotonicNanos();
386
135
    RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>(
387
135
            master_addr.hostname, master_addr.port,
388
135
            [&request, ctx](FrontendServiceConnection& client) {
389
135
                client->streamLoadPut(ctx->put_result, request);
390
135
            }));
391
135
    ctx->put_result.pipeline_params.query_options.__set_enable_strict_cast(false);
392
135
    ctx->stream_load_put_cost_nanos = MonotonicNanos() - stream_load_put_start_time;
393
135
    Status plan_status(Status::create(ctx->put_result.status));
394
135
    if (!plan_status.ok()) {
395
20
        LOG(WARNING) << "plan streaming load failed. errmsg=" << plan_status << ctx->brief();
396
20
        return plan_status;
397
20
    }
398
115
    if (config::is_cloud_mode() && ctx->two_phase_commit && ctx->is_mow_table()) {
399
1
        return Status::NotSupported("http stream 2pc is unsupported for mow table");
400
1
    }
401
114
    ctx->db = ctx->put_result.pipeline_params.db_name;
402
114
    ctx->table = ctx->put_result.pipeline_params.table_name;
403
114
    ctx->txn_id = ctx->put_result.pipeline_params.txn_conf.txn_id;
404
114
    ctx->label = ctx->put_result.pipeline_params.import_label;
405
114
    ctx->put_result.pipeline_params.__set_wal_id(ctx->wal_id);
406
114
    if (http_req != nullptr && http_req->header(HTTP_GROUP_COMMIT) == "async_mode") {
407
        // FIXME find a way to avoid chunked stream load write large WALs
408
12
        size_t content_length = 0;
409
12
        if (!http_req->header(HttpHeaders::CONTENT_LENGTH).empty()) {
410
10
            try {
411
10
                content_length = std::stol(http_req->header(HttpHeaders::CONTENT_LENGTH));
412
10
            } catch (const std::exception& e) {
413
0
                return Status::InvalidArgument("invalid HTTP header CONTENT_LENGTH={}: {}",
414
0
                                               http_req->header(HttpHeaders::CONTENT_LENGTH),
415
0
                                               e.what());
416
0
            }
417
10
            if (is_compressed_file_scan(ctx->put_result.pipeline_params)) {
418
5
                content_length *= 3;
419
5
            }
420
10
        }
421
12
        ctx->put_result.pipeline_params.__set_content_length(content_length);
422
12
    }
423
114
    TPipelineFragmentParamsList mocked;
424
114
    return _exec_env->stream_load_executor()->execute_plan_fragment(ctx, mocked);
425
114
}
426
427
void HttpStreamAction::_save_stream_load_record(std::shared_ptr<StreamLoadContext> ctx,
428
111
                                                const std::string& str) {
429
111
    std::shared_ptr<StreamLoadRecorder> stream_load_recorder =
430
111
            ExecEnv::GetInstance()->storage_engine().get_stream_load_recorder();
431
432
111
    if (stream_load_recorder != nullptr) {
433
111
        std::string key =
434
111
                std::to_string(ctx->start_millis + ctx->load_cost_millis) + "_" + ctx->label;
435
111
        auto st = stream_load_recorder->put(key, str);
436
111
        if (st.ok()) {
437
111
            LOG(INFO) << "put stream_load_record rocksdb successfully. label: " << ctx->label
438
111
                      << ", key: " << key;
439
111
        }
440
111
    } else {
441
0
        LOG(WARNING) << "put stream_load_record rocksdb failed. stream_load_recorder is null.";
442
0
    }
443
111
}
444
445
Status HttpStreamAction::_handle_group_commit(HttpRequest* req,
446
135
                                              std::shared_ptr<StreamLoadContext> ctx) {
447
135
    std::string group_commit_mode = req->header(HTTP_GROUP_COMMIT);
448
135
    if (!group_commit_mode.empty() && !iequal(group_commit_mode, "sync_mode") &&
449
135
        !iequal(group_commit_mode, "async_mode") && !iequal(group_commit_mode, "off_mode")) {
450
0
        return Status::InvalidArgument(
451
0
                "group_commit can only be [async_mode, sync_mode, off_mode]");
452
0
    }
453
135
    if (config::wait_internal_group_commit_finish) {
454
0
        group_commit_mode = "sync_mode";
455
0
    }
456
135
    int64_t content_length = req->header(HttpHeaders::CONTENT_LENGTH).empty()
457
135
                                     ? 0
458
135
                                     : std::stoll(req->header(HttpHeaders::CONTENT_LENGTH));
459
135
    if (content_length < 0) {
460
0
        std::stringstream ss;
461
0
        ss << "This http load content length <0 (" << content_length
462
0
           << "), please check your content length.";
463
0
        LOG(WARNING) << ss.str();
464
0
        return Status::InvalidArgument(ss.str());
465
0
    }
466
    // allow chunked stream load in flink
467
135
    auto is_chunk =
468
135
            !req->header(HttpHeaders::TRANSFER_ENCODING).empty() &&
469
135
            req->header(HttpHeaders::TRANSFER_ENCODING).find("chunked") != std::string::npos;
470
135
    if (group_commit_mode.empty() || iequal(group_commit_mode, "off_mode") ||
471
135
        (content_length == 0 && !is_chunk)) {
472
        // off_mode and empty
473
121
        ctx->group_commit = false;
474
121
        return Status::OK();
475
121
    }
476
14
    if (is_chunk) {
477
2
        ctx->label = "";
478
2
    }
479
480
14
    auto partial_columns = !req->header(HTTP_PARTIAL_COLUMNS).empty() &&
481
14
                           iequal(req->header(HTTP_PARTIAL_COLUMNS), "true");
482
14
    auto temp_partitions = !req->header(HTTP_TEMP_PARTITIONS).empty();
483
14
    auto partitions = !req->header(HTTP_PARTITIONS).empty();
484
14
    if (!partial_columns && !partitions && !temp_partitions && !ctx->two_phase_commit) {
485
14
        if (!config::wait_internal_group_commit_finish && !ctx->label.empty()) {
486
0
            return Status::InvalidArgument("label and group_commit can't be set at the same time");
487
0
        }
488
14
        ctx->group_commit = true;
489
14
        if (iequal(group_commit_mode, "async_mode")) {
490
13
            if (!load_size_smaller_than_wal_limit(content_length)) {
491
0
                std::stringstream ss;
492
0
                ss << "There is no space for group commit http load async WAL. This http load "
493
0
                      "size is "
494
0
                   << content_length << ". WAL dir info: "
495
0
                   << ExecEnv::GetInstance()->wal_mgr()->get_wal_dirs_info_string();
496
0
                LOG(WARNING) << ss.str();
497
0
                return Status::Error<EXCEEDED_LIMIT>(ss.str());
498
0
            }
499
13
        }
500
14
    }
501
14
    return Status::OK();
502
14
}
503
504
} // namespace doris