Skip to content

Commit 61c5620

Browse files
branch-4.0: [fix](schema-change) Prevent coredump when reading non-overlapping segments from a single rowset during heavy schema change #57191 (#57602)
Cherry-picked from #57191 Co-authored-by: Siyang Tang <tangsiyang@selectdb.com>
1 parent a032979 commit 61c5620

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

be/src/olap/schema_change.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Status VSchemaChangeDirectly::_inner_process(RowsetReaderSharedPtr rowset_reader
552552
bool eof = false;
553553
do {
554554
auto new_block = vectorized::Block::create_unique(new_tablet_schema->create_block());
555-
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block());
555+
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block(false));
556556

557557
auto st = rowset_reader->next_block(ref_block.get());
558558
if (!st) {
@@ -621,7 +621,7 @@ Status VBaseSchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset
621621

622622
bool eof = false;
623623
do {
624-
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block());
624+
auto ref_block = vectorized::Block::create_unique(base_tablet_schema->create_block(false));
625625
auto st = rowset_reader->next_block(ref_block.get());
626626
if (!st) {
627627
if (st.is<ErrorCode::END_OF_FILE>()) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
2 2
4+
3 3
5+
4 4
6+
5 5
7+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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_non_overlap_seg_heavy_sc") {
19+
def tblName = "test_non_overlap_seg_heavy_sc"
20+
sql """
21+
DROP TABLE IF EXISTS ${tblName}_src
22+
"""
23+
sql """
24+
CREATE TABLE IF NOT EXISTS ${tblName}_src
25+
(
26+
k INT NOT NULL,
27+
v1 INT NOT NULL,
28+
v2 INT NOT NULL
29+
)
30+
DUPLICATE KEY(k)
31+
DISTRIBUTED BY HASH(k) BUCKETS 5
32+
PROPERTIES(
33+
"replication_num" = "1",
34+
"light_schema_change" = "true",
35+
"disable_auto_compaction" = "true"
36+
);
37+
"""
38+
39+
sql """
40+
DROP TABLE IF EXISTS ${tblName}_dst
41+
"""
42+
sql """
43+
CREATE TABLE IF NOT EXISTS ${tblName}_dst
44+
(
45+
k INT NOT NULL,
46+
v1 INT NOT NULL,
47+
v2 INT NOT NULL
48+
)
49+
DUPLICATE KEY(k)
50+
DISTRIBUTED BY HASH(k) BUCKETS 1
51+
PROPERTIES(
52+
"replication_num" = "1",
53+
"light_schema_change" = "true",
54+
"disable_auto_compaction" = "true"
55+
);
56+
"""
57+
58+
sql """ INSERT INTO ${tblName}_src VALUES (1, 1, 1),(2, 2, 2),(3, 3, 3),(4, 4, 4),(5, 5, 5) """
59+
60+
sql """ INSERT INTO ${tblName}_dst SELECT * FROM ${tblName}_src """
61+
62+
sql """ DELETE FROM ${tblName}_dst WHERE v1 = 1 """
63+
64+
sql """ ALTER TABLE ${tblName}_dst DROP COLUMN v1"""
65+
66+
sql """ ALTER TABLE ${tblName}_dst MODIFY COLUMN v2 STRING NOT NULL """
67+
68+
waitForSchemaChangeDone {
69+
sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tblName}_dst' ORDER BY createtime DESC LIMIT 1 """
70+
time 600
71+
}
72+
73+
qt_sql """ SELECT * FROM ${tblName}_dst ORDER BY k """
74+
}

0 commit comments

Comments
 (0)