-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[test](docker) Verify DML and 3-replica create table when one BE is down #63401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deardeng
wants to merge
1
commit into
apache:master
Choose a base branch
from
deardeng:add-ddl-case
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
regression-test/suites/fault_injection_p0/test_dml_when_one_be_down.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 """ | ||
| def afterUpdate = sql """ SELECT v FROM ${tbl} WHERE k = 1 """ | ||
| assertEquals(1, afterUpdate.size()) | ||
| assertEquals(110, afterUpdate[0][0]) | ||
|
|
||
| // 1.2 delete | ||
| sql """ DELETE FROM ${tbl} WHERE k = 2 """ | ||
| def afterDelete = sql """ SELECT COUNT(*) FROM ${tbl} WHERE k = 2 """ | ||
| assertEquals(0L, afterDelete[0][0]) | ||
|
|
||
| def remainCount = sql """ SELECT COUNT(*) FROM ${tbl} """ | ||
| assertEquals(3L, remainCount[0][0]) | ||
|
|
||
| // 1.3 truncate | ||
| sql """ TRUNCATE TABLE ${tbl} """ | ||
| def afterTrunc = sql """ SELECT COUNT(*) FROM ${tbl} """ | ||
| assertEquals(0L, afterTrunc[0][0]) | ||
|
|
||
| // The table is still writable after truncate. | ||
| sql """ INSERT INTO ${tbl} VALUES (100, 1000), (200, 2000) """ | ||
| def afterReinsert = sql """ SELECT k, v FROM ${tbl} ORDER BY k """ | ||
| assertEquals(2, afterReinsert.size()) | ||
| assertEquals(100, afterReinsert[0][0]) | ||
| assertEquals(1000, afterReinsert[0][1]) | ||
| assertEquals(200, afterReinsert[1][0]) | ||
| assertEquals(2000, afterReinsert[1][1]) | ||
|
|
||
| // ---- 2. Creating a new 3-replica table should still succeed when | ||
| // only 3 BEs are alive. ---- | ||
| def newTbl = "test_create_3replica_when_be_down" | ||
| sql """ DROP TABLE IF EXISTS ${newTbl} """ | ||
| sql """ | ||
| CREATE TABLE ${newTbl} ( | ||
| `k` int NOT NULL, | ||
| `v` int NOT NULL | ||
| ) | ||
| DUPLICATE KEY(`k`) | ||
| DISTRIBUTED BY HASH(`k`) BUCKETS 4 | ||
| PROPERTIES ( | ||
| "replication_allocation" = "tag.location.default: 3" | ||
| ) | ||
| """ | ||
| sql """ INSERT INTO ${newTbl} VALUES (1, 1), (2, 2), (3, 3) """ | ||
| def newCount = sql """ SELECT COUNT(*) FROM ${newTbl} """ | ||
| assertEquals(3L, newCount[0][0]) | ||
|
|
||
| // Replicas should be distributed across the 3 alive BEs. | ||
| def newReplicas = sql_return_maparray("ADMIN SHOW REPLICA DISTRIBUTION FROM ${newTbl}") | ||
| def beWithReplica = newReplicas.count { Integer.valueOf((String) it.ReplicaNum) > 0 } | ||
| assertEquals(3, beWithReplica) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does not guarantee that the
UPDATE/DELETEactually 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 likek = 1andk = 2may 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 inspectingSHOW TABLETS/SHOW TABLETbefore 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.