Copilot commented on code in PR #61954: URL: https://github.com/apache/doris/pull/61954#discussion_r3015256322
########## regression-test/suites/partition_p0/auto_partition/test_auto_partition_retention_restart.groovy: ########## @@ -0,0 +1,82 @@ +// 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 + +suite("test_auto_partition_retention_restart", "docker") { + def options = new ClusterOptions() + options.feNum = 1 + options.beNum = 1 + options.feConfigs += [ + "dynamic_partition_enable=true", + "dynamic_partition_check_interval_seconds=1" + ] + + docker(options) { + def tableName = "test_auto_partition_retention_restart" + + def waitPartitionSize = { int expectedSize, long timeoutMs = 30000L -> + long start = System.currentTimeMillis() + while (System.currentTimeMillis() - start < timeoutMs) { + def partitions = sql "show partitions from ${tableName}" + if (partitions.size() == expectedSize) { + return partitions + } + sleep(1000) + } + def partitions = sql "show partitions from ${tableName}" + assertEquals(partitions.size(), expectedSize) + return partitions + } + + sql "drop table if exists ${tableName} force" + sql """ + create table ${tableName}( + k0 datetime(6) not null + ) + auto partition by range (date_trunc(k0, 'day')) () + distributed by hash(`k0`) buckets 1 + properties( + "replication_num" = "1" + ) + """ + + try { + sql """ + insert into ${tableName} + select date_add('2020-01-01 00:00:00', interval number day) + from numbers("number" = "100") + """ + + sql "alter table ${tableName} set ('partition.retention_count' = '3')" + + cluster.restartFrontends() + sleep(20000) + context.reconnectFe() + + def partitions = waitPartitionSize.call(3) + assertEquals(partitions.size(), 3) + + def rows = sql "select * from ${tableName} order by k0" + assertEquals(rows.size(), 3) + assertEquals(rows[0][0].toString().startsWith("2020-04-07"), true) + assertEquals(rows[2][0].toString().startsWith("2020-04-09"), true) Review Comment: This regression test may pass even if the restart-registration bug still exists, because it never creates any *new* partitions after the FE restart. If retention cleanup happens before `cluster.restartFrontends()` completes, the table could already be down to 3 partitions and remain so after restart even when the scheduler fails to re-register the table. To make this a true restart regression, add an insert after `context.reconnectFe()` that creates at least one new day partition, then assert the scheduler drops back to `partition.retention_count` (e.g., partition count stays at 3 and the oldest day advances). ```suggestion // Insert new data after FE restart to create new day partitions sql """ insert into ${tableName} select date_add('2020-04-10 00:00:00', interval number day) from numbers("number" = "4") """ // After retention runs again, partition count should stay at 3 def partitions = waitPartitionSize.call(3) assertEquals(partitions.size(), 3) def rows = sql "select * from ${tableName} order by k0" assertEquals(rows.size(), 3) // Oldest retained day should advance beyond 2020-04-07 assertEquals(rows[0][0].toString().startsWith("2020-04-11"), true) assertEquals(rows[2][0].toString().startsWith("2020-04-13"), true) ``` -- 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]
