-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[fix](backup) fix backup confict with ddl #42872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
justfortaste
wants to merge
6
commits into
apache:master
from
justfortaste:fix_backup_confict_with_ddl
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a628a9e
[fix](backup) fix backup confict with ddl
justfortaste 7e615b6
add testcase
justfortaste e2e27a9
fix testcase
justfortaste 348b4b7
fix testcase2
justfortaste 30c6ec5
fix review2
justfortaste cbf09f0
Merge branch 'master' into fix_backup_confict_with_ddl
justfortaste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
204 changes: 204 additions & 0 deletions
204
regression-test/suites/backup_restore/test_backup_with_ddl.groovy
This file contains hidden or 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,204 @@ | ||
// 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. | ||
|
||
suite("test_backup_with_ddl") { | ||
|
||
def tableName = "test_backup_with_ddl" | ||
String dbName = "test_backup_with_ddl_db" | ||
|
||
sql """ | ||
ADMIN SET FRONTEND CONFIG ("catalog_trash_expire_second" = "10"); | ||
""" | ||
|
||
def insert_num = 5 | ||
|
||
sql "DROP DATABASE IF EXISTS ${dbName}" | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE if NOT EXISTS ${dbName}.${tableName} | ||
( | ||
`test` INT, | ||
`id` INT | ||
) | ||
ENGINE=OLAP | ||
UNIQUE KEY(`test`, `id`) | ||
DISTRIBUTED BY HASH(id) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
) | ||
""" | ||
|
||
for (int i = 0; i < insert_num; ++i) { | ||
sql """ | ||
INSERT INTO ${dbName}.${tableName} VALUES (1, ${i}) | ||
""" | ||
} | ||
sql " sync " | ||
def res = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(res.size(), insert_num) | ||
|
||
GetDebugPoint().clearDebugPointsForAllFEs() | ||
GetDebugPoint().clearDebugPointsForAllBEs() | ||
|
||
result = sql_return_maparray """show tablets from ${dbName}.${tableName}""" | ||
assertNotNull(result) | ||
def tabletId = null | ||
for (def res1 : result) { | ||
tabletId = res1.TabletId | ||
break | ||
} | ||
|
||
logger.info("========= Test 1: ignore checkBuckupRunning when truncate table ===") | ||
def snapshotName1 = "snapshot_test_1" | ||
|
||
GetDebugPoint().enableDebugPointForAllBEs("SnapshotManager::make_snapshot.wait", [tablet_id:"${tabletId}"]); | ||
|
||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName1} | ||
TO `__keep_on_local__` | ||
ON (${tableName}) | ||
PROPERTIES ("type" = "full") | ||
""" | ||
|
||
GetDebugPoint().enableDebugPointForAllFEs('FE.checkBuckupRunning.ignore', null) | ||
GetDebugPoint().enableDebugPointForAllFEs('FE.CatalogRecycleBin.isExpire', null) | ||
|
||
// wait backup snapshoting | ||
count = 200 // 20s | ||
for (int i = 0; i < count; ++i) { | ||
def records = sql_return_maparray "SHOW BACKUP FROM ${dbName}" | ||
int found = 0 | ||
for (def res2 : records) { | ||
if (res2.State.equals("SNAPSHOTING")) { | ||
found = 1 | ||
break | ||
} | ||
} | ||
if (found == 1) { | ||
break | ||
} | ||
Thread.sleep(100) | ||
} | ||
|
||
// truncate ok | ||
sql """ | ||
truncate table ${dbName}.${tableName}; | ||
""" | ||
|
||
sql "sync" | ||
// assert truncate success | ||
res = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(res.size(), 0) | ||
|
||
sql """ | ||
ADMIN CLEAN TRASH; | ||
""" | ||
|
||
// wait backup canceled, failed to get tablet | ||
count = 1000 // 2000s | ||
def found = 0 | ||
for (int i = 0; i < count; ++i) { | ||
def records = sql_return_maparray "SHOW BACKUP FROM ${dbName}" | ||
found = 0 | ||
for (def res2 : records) { | ||
logger.info("row.State is ${res2.State}") | ||
logger.info("row.TaskErrMsg is ${res2.TaskErrMsg}") | ||
|
||
if (res2.State.equals("CANCELLED") && (res2.TaskErrMsg as String).contains("failed to get tablet")) { | ||
found = 1 | ||
break | ||
} | ||
} | ||
if (found == 1) { | ||
break | ||
} | ||
Thread.sleep(2000) | ||
} | ||
|
||
assertEquals(found, 1) | ||
|
||
syncer.waitSnapshotFinish(dbName) | ||
|
||
GetDebugPoint().disableDebugPointForAllBEs("SnapshotManager::make_snapshot.wait") | ||
GetDebugPoint().disableDebugPointForAllFEs('FE.checkBuckupRunning.ignore') | ||
GetDebugPoint().disableDebugPointForAllFEs('FE.CatalogRecycleBin.isExpire') | ||
|
||
|
||
|
||
logger.info("========= Test 2: checkBuckupRunning when truncate table ===") | ||
def snapshotName2 = "snapshot_test_2" | ||
|
||
for (int i = 0; i < insert_num; ++i) { | ||
sql """ | ||
INSERT INTO ${dbName}.${tableName} VALUES (${i}, ${i}) | ||
""" | ||
} | ||
sql " sync " | ||
|
||
result = sql_return_maparray """show tablets from ${dbName}.${tableName}""" | ||
assertNotNull(result) | ||
tabletId = null | ||
for (def res1 : result) { | ||
tabletId = res1.TabletId | ||
break | ||
} | ||
logger.info("========= show tablet ${tabletId} ===") | ||
|
||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName2} | ||
TO `__keep_on_local__` | ||
ON (${tableName}) | ||
PROPERTIES ("type" = "full") | ||
""" | ||
|
||
// wait backup snapshoting | ||
count = 200 // 20s | ||
found = 0 | ||
for (int i = 0; i < count; ++i) { | ||
def records = sql_return_maparray "SHOW BACKUP FROM ${dbName}" | ||
found = 0 | ||
for (def res2 : records) { | ||
if (res2.State .equals("SNAPSHOTING")) { | ||
found = 1 | ||
break | ||
} | ||
} | ||
if (found == 1) { | ||
break | ||
} | ||
Thread.sleep(100) | ||
} | ||
|
||
assertEquals(found, 1) | ||
|
||
|
||
// truncate fail errCode = 2, detailMessage = Backup is running on this db: test_backup_with_ddl_db | ||
try_sql """ | ||
truncate table ${dbName}.${tableName}; | ||
""" | ||
// assert truncate fail | ||
res = sql "SELECT * FROM ${dbName}.${tableName}" | ||
assertEquals(res.size(), insert_num) | ||
|
||
syncer.waitSnapshotFinish(dbName) | ||
|
||
|
||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql "DROP DATABASE ${dbName} FORCE" | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.