github-actions[bot] commented on code in PR #63401: URL: https://github.com/apache/doris/pull/63401#discussion_r3279084046
########## regression-test/suites/fault_injection_p0/test_dml_when_one_be_down.groovy: ########## @@ -0,0 +1,129 @@ +// 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 + +// Non-cloud (storage-compute integrated) cluster with 1 FE + 4 BE. After +// stopping one BE (3 BE left alive), verify: +// 1. truncate / delete / update on the existing 3-replica table (now with +// only 2 replicas alive per tablet) still work correctly; +// 2. creating a new 3-replica table still succeeds (alive BE count == +// replica count). +suite("test_dml_when_one_be_down", "docker") { + def options = new ClusterOptions() + options.cloudMode = false + options.feNum = 1 + options.beNum = 4 + + docker(options) { + // All 4 BEs are alive at the start. + def aliveBeNum = sql_return_maparray("SHOW BACKENDS") + .count { it.Alive.toString().equalsIgnoreCase("true") } + assertEquals(4, aliveBeNum) + + def tbl = "test_dml_be_down_tbl" + sql """ DROP TABLE IF EXISTS ${tbl} """ + sql """ + CREATE TABLE ${tbl} ( + `k` int NOT NULL, + `v` int NOT NULL + ) + UNIQUE KEY(`k`) + DISTRIBUTED BY HASH(`k`) BUCKETS 4 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 3", + "enable_unique_key_merge_on_write" = "true" + ) + """ + sql """ INSERT INTO ${tbl} VALUES (1, 10), (2, 20), (3, 30), (4, 40) """ + def initCount = sql """ SELECT COUNT(*) FROM ${tbl} """ + assertEquals(4L, initCount[0][0]) + + // Stop BE 1. stopBackends() internally waits ~7s for the FE + // heartbeat to mark the BE as dead. + cluster.stopBackends(1) + cluster.checkBeIsAlive(1, false) + + // Poll SHOW BACKENDS to make sure FE sees only 3 alive BEs. + def alive = 0 + for (int i = 0; i < 60; i++) { + alive = sql_return_maparray("SHOW BACKENDS") + .count { it.Alive.toString().equalsIgnoreCase("true") } + if (alive == 3) { + break + } + sleep(1000) + } + assertEquals(3, alive) + + // ---- 1. update / delete / truncate on the 3-replica table + // (only 2 replicas alive per tablet) ---- + + // 1.1 update: a MOW unique-key table write still satisfies the + // quorum requirement with 2 out of 3 replicas alive. + sql """ UPDATE ${tbl} SET v = v + 100 WHERE k = 1 """ Review Comment: This test does not guarantee that the `UPDATE`/`DELETE` actually hit a tablet that lost a replica when BE 1 was stopped. With 4 BEs and replication 3, some tablets can be placed only on the other three BEs, so fixed keys like `k = 1` and `k = 2` may exercise the normal all-replicas-alive path and still pass even if DML fails for tablets whose replica set includes the stopped BE. Please make the setup deterministic, for example by inspecting `SHOW TABLETS`/`SHOW TABLET` before stopping a BE and choosing the BE and keys/tablets so the exercised DML targets tablets that contain the stopped backend, or by asserting the affected tablets have exactly two alive replicas before running the DML. -- 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]
