github-actions[bot] commented on code in PR #69797: URL: https://github.com/apache/doris/pull/69797#discussion_r4439908228
########## regression-test/suites/fault_injection_p0/test_mow_topn_key_prefix_overlapping_segments.groovy: ########## @@ -0,0 +1,120 @@ +// 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. + +// ORDER BY <key prefix> LIMIT n pushed down to the storage layer on a merge-on-write table +// whose rowset has two segments that overlap on keys. The storage TopN merges the segments of +// a rowset by the ORDER BY columns; rows that are equal on them but differ in the rest of the +// key are different rows and must all come back. Before the fix the merge dropped them as +// older versions of one key: ORDER BY k1 LIMIT 10 returned k1 = 0..9 once each instead of +// k1 = 0..4 twice each. +suite("test_mow_topn_key_prefix_overlapping_segments", "nonConcurrent") { + // Run `insertSql` with MemTable.need_flush on, which flushes every write into its own segment: + // the 16384 rows of numbers("number" = "16384") become two segments of one rowset. One sink + // task writes the Blocks in order, and a Block of 8192 rows is one write on both sinks: the + // legacy sink sends a Block once it holds 8192 rows (VNodeChannel floors its batch size at + // 8192), and the sink with the memtable on it writes every Block. The test is void unless the + // load really wrote an OVERLAPPING rowset with two segments. + def loadTwoOverlappingSegments = { String table, String insertSql -> + try { + GetDebugPoint().enableDebugPointForAllBEs("MemTable.need_flush") + sql "SET parallel_pipeline_task_num = 1" + sql "SET batch_size = 8192" + sql insertSql + } finally { + GetDebugPoint().disableDebugPointForAllBEs("MemTable.need_flush") + } + sql "sync" + def tablets = sql_return_maparray("SHOW TABLETS FROM ${table}") + def (code, out, err) = curl("GET", tablets[0].MetaUrl) + assertEquals(0, code) + def hasMergeLayout = parseJson(out.trim()).rs_metas.any { meta -> + meta.segments_overlap_pb == "OVERLAPPING" && meta.num_segments > 1 + } + assertTrue(hasMergeLayout, "expected an OVERLAPPING rowset with num_segments > 1 in ${table}") + } + // The storage TopN below needs the segment limit pushdown, which the fuzzy session + // variables may turn off. + sql "SET enable_segment_limit_pushdown = true" Review Comment: [P2] Keep the overlapping segments in one scan reader With fuzzy settings such as `enable_parallel_scan=true`, `parallel_scan_max_scanners_count=16` and `parallel_scan_min_rows_per_scanner=128`, `ParallelScannerBuilder` divides this 16,384-row fixture into 1,024-row scanners, each covering only one segment. `BetaRowsetReader::is_merge_iterator()` then returns false, so the metadata assertion and `SORT LIMIT: 10` check both pass even with the production fix reverted: the regression never exercises the merge that used to drop equal-prefix rows. `parallel_pipeline_task_num=1` does not prevent these scanner splits. Disable parallel scanning for these queries, or otherwise ensure one reader merges both segments. -- 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]
