|
| 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 | + |
| 18 | +suite("test_ignore_not_found_segment", "nonConcurrent") { |
| 19 | + def tableName = "test_ignore_not_found_segment_tbl" |
| 20 | + |
| 21 | + def backendId_to_backendIP = [:] |
| 22 | + def backendId_to_backendHttpPort = [:] |
| 23 | + getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort) |
| 24 | + |
| 25 | + def set_be_config = { key, value -> |
| 26 | + for (String backend_id: backendId_to_backendIP.keySet()) { |
| 27 | + def (code, out, err) = update_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), key, value) |
| 28 | + logger.info("set be config ${key}=${value}, code: ${code}, out: ${out}, err: ${err}") |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + sql "DROP TABLE IF EXISTS ${tableName}" |
| 33 | + sql """ |
| 34 | + CREATE TABLE ${tableName} ( |
| 35 | + `k1` int NOT NULL, |
| 36 | + `v1` string NOT NULL |
| 37 | + ) ENGINE=OLAP |
| 38 | + DUPLICATE KEY(`k1`) |
| 39 | + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 |
| 40 | + PROPERTIES ( |
| 41 | + "replication_allocation" = "tag.location.default: 1", |
| 42 | + "disable_auto_compaction" = "true" |
| 43 | + ); |
| 44 | + """ |
| 45 | + |
| 46 | + // Insert data across multiple segments (each INSERT creates a new segment) |
| 47 | + sql "INSERT INTO ${tableName} VALUES (1, 'aaa'), (2, 'bbb');" |
| 48 | + sql "INSERT INTO ${tableName} VALUES (3, 'ccc'), (4, 'ddd');" |
| 49 | + sql "INSERT INTO ${tableName} VALUES (5, 'eee'), (6, 'fff');" |
| 50 | + |
| 51 | + // Verify baseline: all 6 rows are visible |
| 52 | + qt_baseline "SELECT count(*) FROM ${tableName}" |
| 53 | + |
| 54 | + // Test 1: With ignore_not_found_segment=true (default), injecting NOT_FOUND |
| 55 | + // should return partial results (0 rows since all segments fail to load) |
| 56 | + try { |
| 57 | + set_be_config.call("ignore_not_found_segment", "true") |
| 58 | + GetDebugPoint().enableDebugPointForAllBEs("BetaRowset::load_segment.return_not_found") |
| 59 | + |
| 60 | + qt_ignore_enabled "SELECT count(*) FROM ${tableName}" |
| 61 | + } finally { |
| 62 | + GetDebugPoint().disableDebugPointForAllBEs("BetaRowset::load_segment.return_not_found") |
| 63 | + } |
| 64 | + |
| 65 | + // Test 2: With ignore_not_found_segment=false, injecting NOT_FOUND should cause query failure |
| 66 | + try { |
| 67 | + set_be_config.call("ignore_not_found_segment", "false") |
| 68 | + GetDebugPoint().enableDebugPointForAllBEs("BetaRowset::load_segment.return_not_found") |
| 69 | + |
| 70 | + test { |
| 71 | + sql "SELECT count(*) FROM ${tableName}" |
| 72 | + exception "NOT_FOUND" |
| 73 | + } |
| 74 | + } finally { |
| 75 | + GetDebugPoint().disableDebugPointForAllBEs("BetaRowset::load_segment.return_not_found") |
| 76 | + set_be_config.call("ignore_not_found_segment", "true") |
| 77 | + } |
| 78 | + |
| 79 | + // Test 3: After clearing the debug point, data should be fully accessible again |
| 80 | + qt_recovery "SELECT count(*) FROM ${tableName}" |
| 81 | +} |
0 commit comments