forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[opt](compaction) Don't check missed rows in cumu compaction if input…
… rowsets are not in tablet (apache#45279) Problem Summary: Suppose a heavy schema change process on BE converting tablet A to tablet B. 1. during schema change double write, new loads write [X-Y] on tablet B. 2. rowsets with version [a],[a+1],...,[b-1],[b] on tablet B are picked for cumu compaction(X<=a<b<=Y).(cumu compaction on new tablet during schema change double write is allowed after apache#16470) 3. schema change remove all rowsets on tablet B before version Z(b<=Z<=Y) before it begins to convert historical rowsets. 4. schema change finishes. 5. cumu compation begins on new tablet with version [a],...,[b]. If there are duplicate keys between these rowsets, the compaction check will fail because these rowsets have skipped to calculate delete bitmap in commit phase and publish phase because tablet B is in NOT_READY state when writing. This PR makes cumu compaction skip to do missed rows check when it finds out that the input rowsets are not exist in tablet. Note that the compaction will fail because `Tablet::modify_rowsets` will check if rowsets in `to_delete` still exist in tablet's `_rs_version_map`.
- Loading branch information
Showing
8 changed files
with
240 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
regression-test/data/fault_injection_p0/test_compaction_on_sc_new_tablet.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql -- | ||
1 1 1 1 | ||
2 2 2 2 | ||
3 3 3 3 | ||
4 4 4 4 | ||
5 5 5 5 | ||
6 6 6 6 | ||
7 7 7 7 | ||
8 8 8 8 | ||
9 9 9 9 | ||
10 10 10 10 | ||
|
||
-- !sql -- | ||
1 9 9 9 | ||
2 2 2 2 | ||
3 3 3 3 | ||
4 4 4 4 | ||
5 5 5 5 | ||
6 6 6 6 | ||
7 7 7 7 | ||
8 8 8 8 | ||
9 9 9 9 | ||
10 10 10 10 | ||
|
149 changes: 149 additions & 0 deletions
149
regression-test/suites/fault_injection_p0/test_compaction_on_sc_new_tablet.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// 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.junit.Assert | ||
import java.util.concurrent.TimeUnit | ||
import org.awaitility.Awaitility | ||
import org.apache.doris.regression.suite.ClusterOptions | ||
|
||
suite("test_compaction_on_sc_new_tablet", "docker") { | ||
def options = new ClusterOptions() | ||
options.setFeNum(1) | ||
options.setBeNum(1) | ||
options.enableDebugPoints() | ||
options.cloudMode = false | ||
options.beConfigs += [ | ||
'enable_java_support=false', | ||
'enable_mow_compaction_correctness_check_core=true' | ||
] | ||
docker(options) { | ||
try { | ||
GetDebugPoint().clearDebugPointsForAllFEs() | ||
GetDebugPoint().clearDebugPointsForAllBEs() | ||
def table1 = "test_compaction_on_sc_new_tablet" | ||
sql "DROP TABLE IF EXISTS ${table1} FORCE;" | ||
sql """ CREATE TABLE IF NOT EXISTS ${table1} ( | ||
`k` int, | ||
`c1` int, | ||
`c2` int, | ||
`c3` int | ||
) UNIQUE KEY(k) | ||
DISTRIBUTED BY HASH(k) BUCKETS 1 | ||
PROPERTIES ( | ||
"disable_auto_compaction" = "true", | ||
"replication_num" = "1", | ||
"enable_unique_key_merge_on_write" = "true"); """ | ||
|
||
// [2-11] | ||
for (int i = 1; i <= 10; i++) { | ||
sql "insert into ${table1} values($i,$i,$i,$i);" | ||
} | ||
qt_sql "select * from ${table1} order by k;" | ||
|
||
|
||
def beNodes = sql_return_maparray("show backends;") | ||
def tabletStats = sql_return_maparray("show tablets from ${table1};") | ||
logger.info("tabletStats: \n${tabletStats}") | ||
def tabletStat = tabletStats.get(0) | ||
def tabletBackendId = tabletStat.BackendId | ||
def tabletId = tabletStat.TabletId | ||
def version = tabletStat.Version | ||
def tabletBackend; | ||
for (def be : beNodes) { | ||
if (be.BackendId == tabletBackendId) { | ||
tabletBackend = be | ||
break; | ||
} | ||
} | ||
logger.info("tablet ${tabletId} is on backend ${tabletBackend.Host} with backendId=${tabletBackend.BackendId}, version=${version}"); | ||
|
||
// blocking the schema change process before it gains max version | ||
GetDebugPoint().enableDebugPointForAllBEs("SchemaChangeJob::_do_process_alter_tablet.block") | ||
Thread.sleep(2000) | ||
|
||
sql "alter table ${table1} modify column c1 varchar(100);" | ||
|
||
Thread.sleep(4000) | ||
|
||
// double write [11-22] | ||
for (int i = 20; i <= 30; i++) { | ||
sql "insert into ${table1} values(1,9,9,9);" | ||
} | ||
|
||
tabletStats = sql_return_maparray("show tablets from ${table1};") | ||
logger.info("tabletStats: \n${tabletStats}") | ||
assertEquals(2, tabletStats.size()) | ||
|
||
def oldTabletStat | ||
def newTabletStat | ||
for (def stat: tabletStats) { | ||
if (!stat.TabletId.equals(tabletId)) { | ||
newTabletStat = stat | ||
} else { | ||
oldTabletStat = stat | ||
} | ||
} | ||
logger.info("old tablet=[tablet_id=${oldTabletStat.TabletId}, version=${oldTabletStat.Version}]") | ||
logger.info("new tablet=[tablet_id=${newTabletStat.TabletId}, version=${newTabletStat.Version}]") | ||
|
||
|
||
// trigger cumu compaction on new tablet | ||
int start_version = 15 | ||
int end_version = 17 | ||
// block compaction process on new tablet | ||
GetDebugPoint().enableDebugPointForAllBEs("CumulativeCompaction::execute_compact.block", [tablet_id: "${newTabletStat.TabletId}"]) | ||
// manully set cumu compaction's input rowsets on new tablet | ||
GetDebugPoint().enableDebugPointForAllBEs("SizeBasedCumulativeCompactionPolicy::pick_input_rowsets.set_input_rowsets", | ||
[tablet_id:"${newTabletStat.TabletId}", start_version:"${start_version}", end_version:"${end_version}"]) | ||
|
||
Thread.sleep(2000) | ||
|
||
logger.info("trigger compaction [15-17] on new tablet ${newTabletStat.TabletId}") | ||
def (code, out, err) = be_run_cumulative_compaction(tabletBackend.Host, tabletBackend.HttpPort, newTabletStat.TabletId) | ||
logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) | ||
Assert.assertEquals(code, 0) | ||
def compactJson = parseJson(out.trim()) | ||
Assert.assertEquals("success", compactJson.status.toLowerCase()) | ||
|
||
// make the schema change run to complete and wait for it | ||
GetDebugPoint().disableDebugPointForAllBEs("SchemaChangeJob::_do_process_alter_tablet.block") | ||
waitForSchemaChangeDone { | ||
sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${table1}' ORDER BY createtime DESC LIMIT 1 """ | ||
time 2000 | ||
} | ||
|
||
Thread.sleep(2000) | ||
|
||
// make the cumu compaction run to complete and wait for it | ||
GetDebugPoint().disableDebugPointForAllBEs("CumulativeCompaction::execute_compact.block") | ||
|
||
|
||
// BE should skip to check merged rows in cumu compaction, otherwise it will cause coredump | ||
// becasue [11-22] in new tablet will skip to calc delete bitmap becase tablet is in NOT_READY state | ||
Thread.sleep(7000) | ||
|
||
qt_sql "select * from ${table1} order by k;" | ||
|
||
} catch(Exception e) { | ||
logger.info(e.getMessage()) | ||
throw e | ||
} finally { | ||
GetDebugPoint().clearDebugPointsForAllFEs() | ||
GetDebugPoint().clearDebugPointsForAllBEs() | ||
} | ||
} | ||
} |