|
| 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 | +import org.junit.Assert |
| 19 | +import java.util.concurrent.TimeUnit |
| 20 | +import org.awaitility.Awaitility |
| 21 | + |
| 22 | +suite("test_partial_update_with_delete_col_in_publish", "nonConcurrent") { |
| 23 | + |
| 24 | + def tableName = "test_partial_update_with_delete_col_in_publish" |
| 25 | + sql """ DROP TABLE IF EXISTS ${tableName} force;""" |
| 26 | + sql """ CREATE TABLE ${tableName} ( |
| 27 | + `k` int(11) NULL, |
| 28 | + `v1` BIGINT NULL, |
| 29 | + `v2` BIGINT NULL, |
| 30 | + `v3` BIGINT NULL, |
| 31 | + `v4` BIGINT NULL, |
| 32 | + ) UNIQUE KEY(`k`) DISTRIBUTED BY HASH(`k`) BUCKETS 1 |
| 33 | + PROPERTIES( |
| 34 | + "replication_num" = "1", |
| 35 | + "enable_unique_key_merge_on_write" = "true", |
| 36 | + "light_schema_change" = "true", |
| 37 | + "store_row_column" = "false"); """ |
| 38 | + def show_res = sql "show create table ${tableName}" |
| 39 | + sql """insert into ${tableName} values(1,1,1,1,1),(2,2,2,2,2),(3,3,3,3,3),(4,4,4,4,4),(5,5,5,5,5);""" |
| 40 | + qt_sql "select * from ${tableName} order by k;" |
| 41 | + |
| 42 | + def enable_publish_spin_wait = { |
| 43 | + if (isCloudMode()) { |
| 44 | + GetDebugPoint().enableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.enable_spin_wait") |
| 45 | + } else { |
| 46 | + GetDebugPoint().enableDebugPointForAllBEs("EnginePublishVersionTask::execute.enable_spin_wait") |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + def enable_block_in_publish = { |
| 51 | + if (isCloudMode()) { |
| 52 | + GetDebugPoint().enableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.block") |
| 53 | + } else { |
| 54 | + GetDebugPoint().enableDebugPointForAllBEs("EnginePublishVersionTask::execute.block") |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + def disable_block_in_publish = { |
| 59 | + if (isCloudMode()) { |
| 60 | + GetDebugPoint().disableDebugPointForAllFEs("CloudGlobalTransactionMgr.getDeleteBitmapUpdateLock.block") |
| 61 | + } else { |
| 62 | + GetDebugPoint().disableDebugPointForAllBEs("EnginePublishVersionTask::execute.block") |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + try { |
| 67 | + GetDebugPoint().clearDebugPointsForAllFEs() |
| 68 | + GetDebugPoint().clearDebugPointsForAllBEs() |
| 69 | + |
| 70 | + // block the partial update in publish phase |
| 71 | + enable_publish_spin_wait() |
| 72 | + enable_block_in_publish() |
| 73 | + |
| 74 | + def threads = [] |
| 75 | + |
| 76 | + threads << Thread.start { |
| 77 | + sql "set enable_unique_key_partial_update=true;" |
| 78 | + sql "set enable_insert_strict=false" |
| 79 | + sql "sync;" |
| 80 | + sql "insert into ${tableName}(k,v1,v2,__DORIS_DELETE_SIGN__) values(2,222,222,1),(4,-1,-1,0),(5,555,555,1);" |
| 81 | + } |
| 82 | + |
| 83 | + Thread.sleep(500) |
| 84 | + |
| 85 | + threads << Thread.start { |
| 86 | + sql "set enable_unique_key_partial_update=true;" |
| 87 | + sql "sync;" |
| 88 | + sql "insert into ${tableName}(k,v3,v4) values(1,987,987),(2,987,987),(4,987,987),(5,987,987);" |
| 89 | + } |
| 90 | + |
| 91 | + Thread.sleep(500) |
| 92 | + |
| 93 | + disable_block_in_publish() |
| 94 | + threads.each { t -> t.join() } |
| 95 | + |
| 96 | + qt_sql "select * from ${tableName} order by k;" |
| 97 | + } catch(Exception e) { |
| 98 | + logger.info(e.getMessage()) |
| 99 | + throw e |
| 100 | + } finally { |
| 101 | + GetDebugPoint().clearDebugPointsForAllFEs() |
| 102 | + GetDebugPoint().clearDebugPointsForAllBEs() |
| 103 | + } |
| 104 | +} |
0 commit comments