github-actions[bot] commented on code in PR #62481:
URL: https://github.com/apache/doris/pull/62481#discussion_r3087270491


##########
regression-test/suites/load_p0/routine_load/test_routine_load_too_many_tasks_recovery_exactly_once.groovy:
##########
@@ -0,0 +1,177 @@
+// 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.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.RoutineLoadTestUtils
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.junit.Assert
+
+suite("test_routine_load_too_many_tasks_recovery_exactly_once", "docker") {
+    def topicSuffix = System.currentTimeMillis()
+    def kafkaCsvTopic = "test_rl_too_many_tasks_recovery_${topicSuffix}"
+
+    if (!RoutineLoadTestUtils.isKafkaTestEnabled(context)) {
+        return
+    }
+
+    def kafkaPort = context.config.otherConfigs.get("kafka_port")
+    Assert.assertNotNull("kafka_port must be configured in 
regression-conf.groovy", kafkaPort)
+    def kafka_broker = "127.0.0.1:${kafkaPort}"
+

Review Comment:
   Same issue here: in a `docker(options)` case the routine-load job is created 
inside Doris containers, so `127.0.0.1` points at the container itself rather 
than the external Kafka broker. The producer can still publish from the 
host-side test JVM, which makes this especially misleading because the case may 
fail on broker reachability instead of the intended `TOO_MANY_TASKS` 
submit-failure path.



##########
regression-test/suites/load_p0/routine_load/test_routine_load_mow_partial_update_concurrent_compaction.groovy:
##########
@@ -0,0 +1,196 @@
+// 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 groovy.json.JsonSlurper
+import org.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.RoutineLoadTestUtils
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.junit.Assert
+
+suite("test_routine_load_mow_partial_update_concurrent_compaction", "docker") {
+    def topicSuffix = System.currentTimeMillis()
+    def kafkaCsvTopic = "test_rl_mow_pu_concurrent_compaction_${topicSuffix}"
+
+    if (!RoutineLoadTestUtils.isKafkaTestEnabled(context)) {
+        return
+    }
+
+    def kafkaBroker = RoutineLoadTestUtils.getKafkaBroker(context)
+
+    def options = new ClusterOptions()
+    options.setFeNum(1)
+    options.setBeNum(1)
+    options.cloudMode = false
+    options.enableDebugPoints()
+
+    docker(options) {
+        def producer = RoutineLoadTestUtils.createKafkaProducer(kafkaBroker)
+
+        def tableName = "test_rl_mow_pu_concurrent_compaction"
+        def job = "test_mow_pu_concurrent_compaction_job_${topicSuffix}"
+        def compactionDebugPoint = "FullCompaction.modify_rowsets.sleep"
+
+        def waitForLoadedRows = { long expectedLoadedRows, int maxWait = 120 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def res = sql "SHOW ROUTINE LOAD FOR ${job}"
+                def state = res[0][8].toString()
+                def statJson = new 
JsonSlurper().parseText(res[0][14].toString())
+                long loaded = statJson.loadedRows as long
+                logger.info("waitForLoadedRows: state={}, loadedRows={}", 
state, loaded)
+                if (state == "RUNNING" && loaded >= expectedLoadedRows) {
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("loadedRows did not reach ${expectedLoadedRows} within 
timeout")
+        }
+
+        sql """ DROP TABLE IF EXISTS ${tableName} force """
+        sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                `k` int NOT NULL,
+                `c1` int,
+                `c2` int,
+                `c3` int
+            ) ENGINE=OLAP
+            UNIQUE KEY(`k`)
+            DISTRIBUTED BY HASH(`k`) BUCKETS 1
+            PROPERTIES (
+                "replication_allocation" = "tag.location.default: 1",
+                "enable_unique_key_merge_on_write" = "true",
+                "disable_auto_compaction" = "true"
+            );
+        """
+
+        sql """
+            INSERT INTO ${tableName} VALUES
+            (1, 1, 11, 111),
+            (2, 2, 22, 222),
+            (3, 3, 33, 333)
+        """
+        sql "sync"
+
+        def batch1 = [
+            "1,10,110",
+            "2,20,220"
+        ]
+        def batch2 = [
+            "1,11,1110",
+            "3,30,330"
+        ]
+        def batch3 = [
+            "2,21,2210",
+            "3,31,3310"
+        ]
+
+        def compactionError = null
+        Thread compactionThread = null
+
+        try {
+            sql """
+                CREATE ROUTINE LOAD ${job} ON ${tableName}
+                COLUMNS TERMINATED BY ",",
+                COLUMNS (k, c1, c2)
+                PROPERTIES
+                (
+                    "max_batch_interval" = "1",
+                    "partial_columns" = "true"
+                )
+                FROM KAFKA
+                (
+                    "kafka_broker_list" = "${kafkaBroker}",
+                    "kafka_topic" = "${kafkaCsvTopic}",
+                    "property.kafka_default_offsets" = "OFFSET_BEGINNING"
+                );
+            """
+
+            batch1.each { line ->
+                producer.send(new ProducerRecord<>(kafkaCsvTopic, null, 
line)).get()
+            }
+            producer.flush()
+            waitForLoadedRows(2L)
+
+            GetDebugPoint().enableDebugPointForAllBEs(compactionDebugPoint)
+            compactionThread = Thread.start {
+                try {
+                    trigger_and_wait_compaction(tableName, "full")
+                } catch (Throwable t) {
+                    compactionError = t
+                }
+            }
+
+            sleep(2000)

Review Comment:
   These fixed sleeps do not prove that full compaction has actually reached 
`FullCompaction.modify_rowsets.sleep` before batch 2/3 are produced. If 
compaction scheduling is delayed, routine load can consume the later updates 
before compaction enters the intended critical section, and the final table 
assertions will still pass without ever covering the concurrent path. Please 
wait for an explicit signal that compaction is blocked at the debugpoint before 
sending the later Kafka batches.



##########
regression-test/suites/load_p0/routine_load/test_routine_load_mem_limit_exceeded_recovery_exactly_once.groovy:
##########
@@ -0,0 +1,192 @@
+// 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.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.RoutineLoadTestUtils
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.junit.Assert
+
+suite("test_routine_load_mem_limit_exceeded_recovery_exactly_once", "docker") {
+    // 使用时间戳后缀确保每次运行使用不同 topic,避免历史消息污染精确计数断言
+    def topicSuffix = System.currentTimeMillis()
+    def kafkaCsvTopic = "test_rl_mem_limit_recovery_${topicSuffix}"
+
+    if (!RoutineLoadTestUtils.isKafkaTestEnabled(context)) {
+        return
+    }
+
+    def kafkaPort = context.config.otherConfigs.get("kafka_port")
+    Assert.assertNotNull("kafka_port must be configured in 
regression-conf.groovy", kafkaPort)
+    def kafka_broker = "127.0.0.1:${kafkaPort}"

Review Comment:
   `kafka_broker_list` should not be `127.0.0.1` in a `docker(options)` case. 
The producer here runs in the host-side test JVM, so localhost works for 
publishing, but the routine-load job runs inside the FE/BE containers, where 
`127.0.0.1` resolves to the container itself. That means this case can fail on 
Kafka connectivity before it ever exercises the intended `MEM_LIMIT_EXCEEDED` 
recovery path. The other docker routine-load cases in this PR use 
`RoutineLoadTestUtils.getKafkaBroker(context)` for this reason.



##########
regression-test/suites/load_p0/routine_load/test_routine_load_same_job_schema_replay_exactly_once.groovy:
##########
@@ -0,0 +1,215 @@
+// 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.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.RoutineLoadTestUtils
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.junit.Assert
+
+// 语义说明:
+// Routine Load 因 strict_mode/schema mismatch 暂停后,RESUME 不会回放历史坏数据,
+// 只会继续消费恢复后追加的新数据。
+suite("test_routine_load_resume_without_replay_after_schema_pause", "docker") {
+    def topicSuffix = System.currentTimeMillis()
+    def kafkaCsvTopic = "test_rl_resume_no_replay_${topicSuffix}"
+
+    if (!RoutineLoadTestUtils.isKafkaTestEnabled(context)) {
+        return
+    }
+
+    def kafkaBroker = RoutineLoadTestUtils.getKafkaBroker(context)
+
+    def options = new ClusterOptions()
+    options.setFeNum(1)
+    options.setBeNum(1)
+    options.cloudMode = false
+
+    docker(options) {
+        def producer = RoutineLoadTestUtils.createKafkaProducer(kafkaBroker)
+
+        def tableName = "test_rl_resume_no_replay"
+        def job = "test_rl_resume_no_replay_job_${topicSuffix}"
+
+        def schemaRejectedData = [
+            "1,aaa,2023-01-01,val1,2023-01-01 10:00:00,abcdef",
+            "2,bbb,2023-01-02,val2,2023-01-02 11:00:00,ghijkl"
+        ]
+        def postResumeData = [
+            "3,ccc,2023-01-03,val3,2023-01-03 12:00:00,hello1",
+            "4,ddd,2023-01-04,val4,2023-01-04 13:00:00,world2"
+        ]
+
+        def waitForPaused = { int maxWait = 60 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def res = sql "SHOW ROUTINE LOAD FOR ${job}"
+                def state = res[0][8].toString()
+                if (state == "PAUSED") {
+                    logger.info("Job paused as expected. reason={}", 
res[0][17].toString())
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Routine load job did not enter PAUSED within timeout")
+        }
+
+        def waitForSchemaChangeFinished = { int maxWait = 120 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def alterRes = sql "SHOW ALTER TABLE COLUMN WHERE 
TableName='${tableName}' ORDER BY CreateTime DESC LIMIT 1"
+                if (alterRes.size() > 0 && alterRes[0][9].toString() == 
"FINISHED") {
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Schema change did not finish within timeout")
+        }
+
+        def waitForExactRowCount = { long expected, int maxWait = 120 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def jobRes = sql "SHOW ROUTINE LOAD FOR ${job}"
+                def state = jobRes[0][8].toString()
+                def countRes = sql "SELECT count(*) FROM ${tableName}"
+                long rowCount = (countRes[0][0] as Number).longValue()
+                logger.info("waitForExactRowCount: state={}, rows={}", state, 
rowCount)
+                if (state == "RUNNING" && rowCount == expected) {
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Row count did not reach ${expected} within timeout")
+        }
+
+        def waitForRunning = { int maxWait = 60 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def jobRes = sql "SHOW ROUTINE LOAD FOR ${job}"
+                def state = jobRes[0][8].toString()
+                if (state == "RUNNING") {
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Routine load job did not enter RUNNING within 
timeout")
+        }
+
+        def assertRowCountKeeps = { long expected, int observeSeconds = 5 ->
+            for (int i = 0; i < observeSeconds; i++) {
+                def countRes = sql "SELECT count(*) FROM ${tableName}"
+                long rowCount = (countRes[0][0] as Number).longValue()
+                logger.info("assertRowCountKeeps: second={}, rows={}", i, 
rowCount)
+                Assert.assertEquals("Observed row count should stay at 
${expected}", expected, rowCount)
+                sleep(1000)
+            }
+        }
+
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                `k1` int(20) NULL,
+                `k2` string NULL,
+                `v1` date NULL,
+                `v2` string NULL,
+                `v3` datetime NULL,
+                `v4` varchar(5) NULL
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`k1`)
+            DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+            PROPERTIES ("replication_allocation" = "tag.location.default: 1");
+        """
+        sql "sync"
+
+        schemaRejectedData.each { line ->
+            logger.info("Sending schema-blocked row to Kafka: {}", line)
+            producer.send(new ProducerRecord<>(kafkaCsvTopic, null, 
line)).get()
+        }
+        producer.flush()
+
+        try {
+            sql """
+                CREATE ROUTINE LOAD ${job} ON ${tableName}
+                COLUMNS TERMINATED BY ","
+                PROPERTIES
+                (
+                    "strict_mode" = "true",
+                    "max_batch_interval" = "5",
+                    "max_batch_rows" = "300000",
+                    "max_batch_size" = "209715200"
+                )
+                FROM KAFKA
+                (
+                    "kafka_broker_list" = "${kafkaBroker}",
+                    "kafka_topic" = "${kafkaCsvTopic}",
+                    "property.kafka_default_offsets" = "OFFSET_BEGINNING"
+                );
+            """
+            sql "sync"
+
+            waitForPaused()
+
+            def pausedCount = sql "SELECT count(*) FROM ${tableName}"
+            Assert.assertEquals("PAUSED 期间不应写入任何行", 0L, (pausedCount[0][0] as 
Number).longValue())
+
+            sql "ALTER TABLE ${tableName} MODIFY COLUMN v4 VARCHAR(10)"
+            waitForSchemaChangeFinished()
+
+            sql "RESUME ROUTINE LOAD FOR ${job}"
+            waitForRunning()
+            assertRowCountKeeps(0L)

Review Comment:
   This is asserting the opposite of current Kafka routine-load semantics. For 
aborted tasks we do **not** advance Kafka progress 
(`KafkaRoutineLoadJob.checkCommitInfo()` returns false on `ABORTED`), and task 
renewal/resume rebuilds from the job's current offsets. After widening `v4` and 
resuming the same job, rows `1/2` should be retried and become loadable. 
Existing `test_routine_load_with_sc.groovy` already depends on that behavior. 
As written this case would fail on correct code and would document the wrong 
contract if it passed.



##########
regression-test/suites/load_p0/routine_load/test_routine_load_master_switch_exactly_once.groovy:
##########
@@ -0,0 +1,194 @@
+// 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.apache.doris.regression.Config
+import org.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.RoutineLoadTestUtils
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.junit.Assert
+
+suite("test_routine_load_master_switch_exactly_once", "docker") {
+    def topicSuffix = System.currentTimeMillis()
+    def kafkaCsvTopic = "test_rl_master_switch_${topicSuffix}"
+
+    if (!RoutineLoadTestUtils.isKafkaTestEnabled(context)) {
+        return
+    }
+
+    def kafkaBroker = RoutineLoadTestUtils.getKafkaBroker(context)
+
+    def options = new ClusterOptions()
+    options.setFeNum(3)
+    options.setBeNum(1)
+    options.cloudMode = false
+
+    docker(options) {
+        def producer = RoutineLoadTestUtils.createKafkaProducer(kafkaBroker)
+
+        def tableName = "test_rl_master_switch_exactly_once"
+        def job = "test_rl_master_switch_job_${topicSuffix}"
+        Integer oldMasterIndex = null
+
+        def firstBatch = (1..30).collect { i ->
+            "${i},payload_${i},2026-04-${String.format('%02d', (i % 28) + 
1)}".toString()
+        }
+        def secondBatch = (31..40).collect { i ->
+            "${i},payload_${i},2026-04-${String.format('%02d', (i % 28) + 
1)}".toString()
+        }
+
+        def waitForRowCountAtLeast = { long expectedMinRows, int maxWait = 120 
->
+            def waited = 0
+            while (waited < maxWait) {
+                def rowCount = sql "SELECT count(*) FROM ${tableName}"
+                long count = (rowCount[0][0] as Number).longValue()
+                if (count >= expectedMinRows) {
+                    return count
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Row count did not reach ${expectedMinRows} within 
timeout")
+        }
+
+        def waitForExactRowCount = { long expected, int maxWait = 180 ->
+            def waited = 0
+            while (waited < maxWait) {
+                def state = sql "SHOW ROUTINE LOAD FOR ${job}"
+                def rowCount = sql "SELECT count(*) FROM ${tableName}"
+                long count = (rowCount[0][0] as Number).longValue()
+                logger.info("waitForExactRowCount: state={}, rows={}", 
state[0][8].toString(), count)
+                if (state[0][8].toString() == "RUNNING" && count == expected) {
+                    return
+                }
+                sleep(1000)
+                waited++
+            }
+            Assert.fail("Row count did not reach ${expected} within timeout")
+        }
+
+        def reconnectToCurrentMaster = {
+            def currentMaster = cluster.getMasterFe()
+            Assert.assertNotNull("Current master FE should exist", 
currentMaster)
+            def masterJdbcUrl = Config.buildUrlWithDb(currentMaster.host, 
currentMaster.queryPort, context.dbName)
+            context.connectTo(masterJdbcUrl, context.config.jdbcUser, 
context.config.jdbcPassword)
+        }
+
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                `id` int NOT NULL,
+                `payload` string NULL,
+                `ts` string NULL
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`id`)
+            DISTRIBUTED BY HASH(`id`) BUCKETS 1
+            PROPERTIES ("replication_allocation" = "tag.location.default: 1");
+        """
+        sql "sync"
+
+        try {
+            firstBatch.each { line ->
+                producer.send(new ProducerRecord<>(kafkaCsvTopic, null, 
line)).get()
+            }
+            producer.flush()
+
+            sql """
+                CREATE ROUTINE LOAD ${job} ON ${tableName}
+                COLUMNS TERMINATED BY ","
+                PROPERTIES
+                (
+                    "max_batch_interval" = "5"
+                )
+                FROM KAFKA
+                (
+                    "kafka_broker_list" = "${kafkaBroker}",
+                    "kafka_topic" = "${kafkaCsvTopic}",
+                    "property.kafka_default_offsets" = "OFFSET_BEGINNING"
+                );
+            """
+
+            waitForRowCountAtLeast(1L)

Review Comment:
   `count(*) >= 1` is not a strong enough synchronization point for an 
exactly-once failover case. By the time this condition becomes true, the first 
task may already have committed/visible'd all 30 rows, so killing the master 
only tests "the job keeps running after leader switch", not replay/idempotence 
around an in-flight master failover. Can we stop the leader at a known 
in-flight point (for example with a debugpoint or task/txn-level state check) 
instead?



-- 
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]

Reply via email to