github-actions[bot] commented on code in PR #62804: URL: https://github.com/apache/doris/pull/62804#discussion_r3144712720
########## regression-test/suites/job_p0/streaming_job/test_streaming_insert_job_file_number.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + +import org.awaitility.Awaitility + +import static java.util.concurrent.TimeUnit.SECONDS + +// fileNumber must be physical file count, not BE split count. Tiny split_size forces multi-split per file. +suite("test_streaming_insert_job_file_number") { + def tableName = "test_streaming_insert_job_file_number_tbl" + def jobName = "test_streaming_insert_job_file_number_name" + + sql """drop table if exists `${tableName}` force""" + sql """ + DROP JOB IF EXISTS where jobname = '${jobName}' + """ + + sql """ + CREATE TABLE IF NOT EXISTS ${tableName} ( + `c1` int NULL, + `c2` string NULL, + `c3` int NULL + ) ENGINE=OLAP + DUPLICATE KEY(`c1`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`c1`) BUCKETS 3 + PROPERTIES ("replication_allocation" = "tag.location.default: 1"); + """ + + sql """ + CREATE JOB ${jobName} + PROPERTIES( + "s3.max_batch_files" = "2", + "session.max_initial_file_split_size" = "50" + ) + ON STREAMING DO INSERT INTO ${tableName} + SELECT * FROM S3 + ( + "uri" = "s3://${s3BucketName}/regression/load/data/example_[0-1].csv", + "format" = "csv", + "provider" = "${getS3Provider()}", + "column_separator" = ",", + "s3.endpoint" = "${getS3Endpoint()}", + "s3.region" = "${getS3Region()}", + "s3.access_key" = "${getS3AK()}", + "s3.secret_key" = "${getS3SK()}" + ); + """ + + try { + Awaitility.await().atMost(300, SECONDS) + .pollInterval(1, SECONDS).until( + { + def jobSuccendCount = sql """ select SucceedTaskCount from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING' """ + log.info("jobSuccendCount: " + jobSuccendCount) + jobSuccendCount.size() == 1 && '1' <= jobSuccendCount.get(0).get(0) + } + ) + } catch (Exception ex) { + def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'""" + def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'""" + log.info("show job: " + showjob) + log.info("show task: " + showtask) + throw ex; + } + + sql """ PAUSE JOB where jobname = '${jobName}' """ + + def jobInfo = sql """ + select loadStatistic from jobs("type"="insert") where Name='${jobName}' + """ + log.info("jobInfo: " + jobInfo) + def loadStat = parseJson(jobInfo.get(0).get(0)) + assert loadStat.scannedRows == 20 + assert loadStat.loadBytes == 425 + assert loadStat.fileSize == 256 + // Without fix this is BE split count (6); with fix it's physical file count (2). + assert loadStat.fileNumber == 2 + + qt_select """ SELECT * FROM ${tableName} order by c1 """ Review Comment: This suite adds `qt_select`, but the patch does not add the corresponding baseline file `regression-test/data/job_p0/streaming_job/test_streaming_insert_job_file_number.out`. The regression framework will fail to validate the query result without that generated `.out` file, so the new coverage is incomplete as submitted. ########## fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java: ########## @@ -1045,21 +1045,24 @@ public void beforeCommitted(TransactionState txnState) throws TransactionExcepti LoadJob loadJob = loadJobs.get(0); LoadStatistic loadStatistic = loadJob.getLoadStatistic(); + Offset runningOffset = runningStreamTask.getRunningOffset(); String offsetJson = offsetProvider.getCommitOffsetJson( - runningStreamTask.getRunningOffset(), + runningOffset, runningStreamTask.getTaskId(), runningStreamTask.getScanBackendIds()); if (StringUtils.isBlank(offsetJson)) { throw new TransactionException("Cannot find offset for attachment, load job id is " + runningStreamTask.getTaskId()); } + int physicalFileNum = runningOffset.getPhysicalFileNum(); + long numFiles = physicalFileNum >= 0 ? physicalFileNum : loadStatistic.getFileNumber(); Review Comment: Changing `numFiles` here only affects attachments created after the upgrade. The cumulative totals that `jobs()` shows are already persisted in `StreamingInsertJob.jobStatistic` and, in cloud mode, in the meta-service's `streaming_job` record; both paths keep adding the new `numFiles` value on top of the old split-based total. For a long-running job that already committed tasks before upgrading, `LoadStatistic.FileNumber` will stay mixed indefinitely rather than converging to physical file counts. We need a migration/reset path (or to scope this to newly created jobs) before treating the field as fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
