Coverage Report

Created: 2026-08-14 12:43

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