|
| 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 | +import org.apache.doris.regression.suite.ClusterOptions |
| 18 | +import org.apache.doris.regression.util.NodeType |
| 19 | +import org.apache.doris.regression.suite.SuiteCluster |
| 20 | + |
| 21 | +suite("test_retry_be_restart", "p0, docker") { |
| 22 | + if (!isCloudMode()) { |
| 23 | + return |
| 24 | + } |
| 25 | + def options = new ClusterOptions() |
| 26 | + options.enableDebugPoints() |
| 27 | + options.setFeNum(1) |
| 28 | + options.feConfigs.add('max_query_retry_time=100') |
| 29 | + options.feConfigs.add('sys_log_verbose_modules=org') |
| 30 | + options.setBeNum(1) |
| 31 | + options.cloudMode = true |
| 32 | + // 1. connect to master |
| 33 | + options.connectToFollower = false |
| 34 | + |
| 35 | + def queryTask = { |
| 36 | + for (int i = 0; i < 100; i++) { |
| 37 | + try { |
| 38 | + log.info("query count: {}", i) |
| 39 | + sql """select * from test_be_restart_table""" |
| 40 | + Thread.sleep(100) |
| 41 | + } catch (Exception e) { |
| 42 | + logger.warn("select failed: ${e.message}") |
| 43 | + assertFalse(true); |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + def pointSelectQueryTask = { |
| 49 | + for (int i = 0; i < 100; i++) { |
| 50 | + try { |
| 51 | + log.info("query count: {}", i) |
| 52 | + sql """select * from test_be_restart_table where account=1 and site_code=1""" |
| 53 | + Thread.sleep(100) |
| 54 | + } catch (Exception e) { |
| 55 | + logger.warn("select failed: ${e.message}") |
| 56 | + assertFalse(true); |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + docker(options) { |
| 62 | + def be1 = cluster.getBeByIndex(1) |
| 63 | + def beId = be1.backendId; |
| 64 | + |
| 65 | + sql """ |
| 66 | + CREATE TABLE IF NOT EXISTS `test_be_restart_table` |
| 67 | + ( |
| 68 | + `account` bigint NULL COMMENT '用户ID', |
| 69 | + `site_code` int NULL COMMENT '站点代码', |
| 70 | + `site_code_str` varchar(64) NOT NULL DEFAULT "" COMMENT 'string类型站点编号,查询返回数据使用', |
| 71 | + `register_time` datetime(3) NULL COMMENT '注册时间,tidb中为int,需要转换', |
| 72 | + `increment_no` bigint NOT NULL AUTO_INCREMENT(1), |
| 73 | + `currency` varchar(65533) NULL COMMENT '币种' |
| 74 | + ) |
| 75 | + ENGINE=OLAP |
| 76 | + UNIQUE KEY(`account`, `site_code`) |
| 77 | + PARTITION BY LIST(`site_code`) |
| 78 | + ( |
| 79 | + PARTITION p_1 VALUES IN (1), |
| 80 | + PARTITION p_2 VALUES IN (2) |
| 81 | + ) |
| 82 | + DISTRIBUTED BY HASH(`account`) BUCKETS 8 |
| 83 | + PROPERTIES ( |
| 84 | + "binlog.enable" = "true", |
| 85 | + "replication_num" = "1", |
| 86 | + "enable_unique_key_merge_on_write" = "true" |
| 87 | + ); |
| 88 | + """ |
| 89 | + sql """ |
| 90 | + INSERT INTO test_be_restart_table VALUES (1, 1, '1', '2026-01-01 00:00:00', 1, 'USD'); |
| 91 | + """ |
| 92 | + sql """ |
| 93 | + INSERT INTO test_be_restart_table VALUES (2, 2, '2', '2026-01-01 00:00:00', 2, 'EUR'); |
| 94 | + """ |
| 95 | + sql """ |
| 96 | + INSERT INTO test_be_restart_table VALUES (3, 1, '3', '2026-01-01 00:00:00', 3, 'GBP'); |
| 97 | + """ |
| 98 | + |
| 99 | + def result = sql """select account, site_code from test_be_restart_table order by account, site_code;""" |
| 100 | + log.info("insert result : {}", result) |
| 101 | + assertEquals([[1L, 1], [2L, 2], [3L, 1]], result) |
| 102 | + cluster.injectDebugPoints(NodeType.FE, ['StmtExecutor.retry.longtime' : null]) |
| 103 | + // this should be run at least 10 seconds |
| 104 | + def queryThread = Thread.start(queryTask) |
| 105 | + def pointSelectQueryThread = Thread.start(pointSelectQueryTask) |
| 106 | + sleep(5 * 1000) |
| 107 | + cluster.restartBackends() |
| 108 | + // query should have no failure |
| 109 | + // wait query thread finish |
| 110 | + queryThread.join(15000) |
| 111 | + pointSelectQueryThread.join(15000) |
| 112 | + } |
| 113 | +} |
| 114 | + |
0 commit comments