-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
404 additions
and
49 deletions.
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
140 changes: 94 additions & 46 deletions
140
fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
96 changes: 96 additions & 0 deletions
96
regression-test/suites/backup_restore/test_backup_restore_force_replace_diff_column.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,96 @@ | ||
// 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_restore_force_replace_diff_column", "backup_restore") { | ||
String suiteName = "test_backup_restore_force_replace_diff_column" | ||
String dbName = "${suiteName}_db_0" | ||
String repoName = "repo_" + UUID.randomUUID().toString().replace("-", "") | ||
String snapshotName = "${suiteName}_snapshot_" + System.currentTimeMillis() | ||
String tableNamePrefix = "${suiteName}_tables" | ||
String tableName = "${tableNamePrefix}_0" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
sql "DROP DATABASE IF EXISTS ${dbName}" | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
|
||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0" | ||
) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
ON ( | ||
${tableName} | ||
) | ||
""" | ||
|
||
syncer.waitSnapshotFinish(dbName) | ||
|
||
def snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
sql "DROP TABLE ${dbName}.${tableName}" | ||
|
||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT DEFAULT "0", | ||
`desc` VARCHAR(20) DEFAULT "" | ||
) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"reserve_replica" = "true", | ||
"atomic_restore" = "true", | ||
"force_replace" = "true" | ||
) | ||
""" | ||
|
||
syncer.waitAllRestoreFinish(dbName) | ||
|
||
sql "sync" | ||
def desc_res = sql "desc ${dbName}.${tableName}" | ||
assertEquals(desc_res.size(), 2) | ||
} | ||
|
97 changes: 97 additions & 0 deletions
97
...ession-test/suites/backup_restore/test_backup_restore_force_replace_diff_part_type.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,97 @@ | ||
// 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_restore_force_replace_diff_part_type", "backup_restore") { | ||
String suiteName = "test_backup_restore_force_replace_diff_part_type" | ||
String dbName = "${suiteName}_db_0" | ||
String repoName = "repo_" + UUID.randomUUID().toString().replace("-", "") | ||
String snapshotName = "${suiteName}_snapshot_" + System.currentTimeMillis() | ||
String tableNamePrefix = "${suiteName}_tables" | ||
String tableName = "${tableNamePrefix}_0" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
sql "DROP DATABASE IF EXISTS ${dbName}" | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
|
||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`) | ||
PARTITION BY LIST(`id`) | ||
( | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
ON ( | ||
${tableName} | ||
) | ||
""" | ||
|
||
syncer.waitSnapshotFinish(dbName) | ||
|
||
def snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
sql "DROP TABLE ${dbName}.${tableName}" | ||
|
||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`, `count`) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"reserve_replica" = "true", | ||
"atomic_restore" = "true", | ||
"force_replace" = "true" | ||
) | ||
""" | ||
|
||
syncer.waitAllRestoreFinish(dbName) | ||
|
||
sql "sync" | ||
def show_table = sql "show create table ${dbName}.${tableName}" | ||
assertTrue(show_table[0][1].contains("PARTITION BY LIST (`id`)")) | ||
} | ||
|
101 changes: 101 additions & 0 deletions
101
regression-test/suites/backup_restore/test_backup_restore_force_replace_diff_part_val.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,101 @@ | ||
// 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_restore_force_replace_diff_part_val", "backup_restore") { | ||
String suiteName = "test_backup_restore_force_replace_diff_part_val" | ||
String dbName = "${suiteName}_db_0" | ||
String repoName = "repo_" + UUID.randomUUID().toString().replace("-", "") | ||
String snapshotName = "${suiteName}_snapshot_" + System.currentTimeMillis() | ||
String tableNamePrefix = "${suiteName}_tables" | ||
String tableName = "${tableNamePrefix}_0" | ||
|
||
def syncer = getSyncer() | ||
syncer.createS3Repository(repoName) | ||
sql "CREATE DATABASE IF NOT EXISTS ${dbName}" | ||
|
||
sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" | ||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT SUM DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`) | ||
PARTITION BY RANGE(`id`) | ||
( | ||
PARTITION p0 VALUES LESS THAN ("10") | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
BACKUP SNAPSHOT ${dbName}.${snapshotName} | ||
TO `${repoName}` | ||
ON ( | ||
${tableName} | ||
) | ||
""" | ||
|
||
syncer.waitSnapshotFinish(dbName) | ||
|
||
def snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName) | ||
assertTrue(snapshot != null) | ||
|
||
sql "DROP TABLE ${dbName}.${tableName}" | ||
|
||
sql """ | ||
CREATE TABLE ${dbName}.${tableName} ( | ||
`id` LARGEINT NOT NULL, | ||
`count` LARGEINT DEFAULT "0" | ||
) | ||
AGGREGATE KEY(`id`, `count`) | ||
PARTITION BY RANGE(`id`, `count`) | ||
( | ||
PARTITION p0 VALUES LESS THAN ("100") | ||
) | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql """ | ||
RESTORE SNAPSHOT ${dbName}.${snapshotName} | ||
FROM `${repoName}` | ||
PROPERTIES | ||
( | ||
"backup_timestamp" = "${snapshot}", | ||
"reserve_replica" = "true", | ||
"atomic_restore" = "true", | ||
"force_replace" = "true" | ||
) | ||
""" | ||
|
||
syncer.waitAllRestoreFinish(dbName) | ||
|
||
sql "sync" | ||
def show_partitions = sql_return_maparray "SHOW PARTITIONS FROM ${dbName}.${tableName} where PartitionName = 'p0'" | ||
|
||
logger.info(show_partitions.Range) | ||
|
||
assertTrue(show_partitions.Range.contains("[types: [LARGEINT]; keys: [-170141183460469231731687303715884105728]; ..types: [LARGEINT]; keys: [10]; )")) | ||
} | ||
|