hello-stephen commented on code in PR #71334: URL: https://github.com/apache/doris/pull/71334#discussion_r4781269787
########## regression-test/suites/clone_p0/test_clone_multi_analyzer_index_ids.groovy: ########## @@ -0,0 +1,139 @@ +// 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 +import org.apache.doris.regression.util.NodeType + +// An incremental clone must keep the ids of two inverted indexes on one column. +suite('test_clone_multi_analyzer_index_ids', 'docker') { + def options = new ClusterOptions() + options.feConfigs += [ + 'disable_tablet_scheduler=true', + 'tablet_checker_interval_ms=500', + 'schedule_batch_size=1000', + 'schedule_slot_num_per_hdd_path=1000', + ] + options.beConfigs += [ + 'report_tablet_interval_seconds=1', + 'report_index_policy_interval_seconds=1', + ] + + options.enableDebugPoints() + options.cloudMode = false + docker(options) { + def injectName = 'TxnManager.prepare_txn.random_failed' + def be = sql_return_maparray('show backends').get(0) + def addInject = { -> + GetDebugPoint().enableDebugPoint(be.Host, be.HttpPort as int, NodeType.BE, injectName, [percent:1.0]) + } + def deleteInject = { -> + GetDebugPoint().disableDebugPoint(be.Host, be.HttpPort as int, NodeType.BE, injectName) + } + def lostReplica = { -> + sql_return_maparray('show tablets from clone_multi_analyzer').find { + it.BackendId.toLong().equals(be.BackendId.toLong()) + } + } + + // A cached result would hide which replica answered the query. + sql "SET enable_sql_cache = false" + + sql """CREATE INVERTED INDEX ANALYZER IF NOT EXISTS clone_std_analyzer + PROPERTIES ("tokenizer" = "standard", "token_filter" = "lowercase")""" + sql """CREATE INVERTED INDEX ANALYZER IF NOT EXISTS clone_kw_analyzer + PROPERTIES ("tokenizer" = "keyword", "token_filter" = "lowercase")""" + + // BEs get new analyzers asynchronously, so probe both analyzers on every replica first. + sql "DROP TABLE IF EXISTS clone_analyzer_probe" + sql "CREATE TABLE clone_analyzer_probe (k INT) DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1" + sql "INSERT INTO clone_analyzer_probe VALUES (1)" + // use_fix_replica picks among queryable replicas only, so all three must hold the row. + awaitUntil(60) { + def probeReplicas = sql_return_maparray('show tablets from clone_analyzer_probe') + probeReplicas.size() == 3 && probeReplicas.every { + it.Version.toLong() == 2 && it.LstFailedVersion.toLong() == -1 + } + } + awaitUntil(60) { + (0..2).every { i -> + sql "SET use_fix_replica = ${i}" + try { + sql """SELECT tokenize(CAST(k AS STRING), '"analyzer"="clone_std_analyzer"'), + tokenize(CAST(k AS STRING), '"analyzer"="clone_kw_analyzer"') + FROM clone_analyzer_probe""" + return true + } catch (Exception e) { + assertTrue(e.message.contains('Policy not found'), e.message) + return false + } + } + } + sql "SET use_fix_replica = -1" + + sql """ + CREATE TABLE clone_multi_analyzer ( + k INT, + txt STRING, + INDEX idx_std (txt) USING INVERTED PROPERTIES("analyzer" = "clone_std_analyzer"), + INDEX idx_kw (txt) USING INVERTED PROPERTIES("analyzer" = "clone_kw_analyzer") + ) DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ( + "disable_auto_compaction" = "true" + ) + """ + + sql "INSERT INTO clone_multi_analyzer VALUES (1, 'alice')" + + // The first backend misses versions 3 and 4, which an incremental clone fills later. + addInject() + sql "INSERT INTO clone_multi_analyzer VALUES (2, 'alice cooper')" + sql "INSERT INTO clone_multi_analyzer VALUES (3, 'bob')" + deleteInject() + sql "INSERT INTO clone_multi_analyzer VALUES (4, 'Alice')" + + sleep(5000) + def replica = lostReplica() + assertNotNull(replica) + assertEquals(2, replica.Version.toInteger()) + assertEquals(4, replica.LstFailedVersion.toInteger()) + + setFeConfig('disable_tablet_scheduler', false) + awaitUntil(60) { + replica = lostReplica() + replica.Version.toInteger() == 5 && replica.LstFailedVersion.toInteger() == -1 + } + + def checkEveryReplica = { -> + for (int i = 0; i < 3; i++) { + sql "SET use_fix_replica = ${i}" + order_qt_std "SELECT k FROM clone_multi_analyzer WHERE txt MATCH 'alice' USING ANALYZER clone_std_analyzer" Review Comment: [P3] Require index-backed MATCH in the replica checks If the repaired replica is missing an analyzer's index, the default fallback evaluates MATCH against the stored text with the same analyzer and can return the expected keys. This can mask a missing index in either the cloned or compacted rowsets. Set `enable_match_without_inverted_index = false` before both query passes so the test requires usable indexes. -- 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]
