w41ter commented on code in PR #49849:
URL: https://github.com/apache/doris/pull/49849#discussion_r2032284759


##########
regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy:
##########
@@ -439,6 +439,38 @@ class Syncer {
         allDone
     }
 
+    Boolean checkRestoreError(String dbName = null, String message = null) {
+        if (dbName == null) {
+            dbName = context.db
+        }
+        String checkSQL = "SHOW RESTORE FROM ${dbName}"
+        def records = suite.sql(checkSQL)
+        def haveError = false
+        def expectMessage = (message == null)
+        for (row in records) {

Review Comment:
   ```suggestion
           for (def row in records) {
   ```



##########
regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy:
##########
@@ -439,6 +439,38 @@ class Syncer {
         allDone
     }
 
+    Boolean checkRestoreError(String dbName = null, String message = null) {
+        if (dbName == null) {
+            dbName = context.db
+        }
+        String checkSQL = "SHOW RESTORE FROM ${dbName}"
+        def records = suite.sql(checkSQL)
+        def haveError = false
+        def expectMessage = (message == null)
+        for (row in records) {
+            logger.info("Restore row is ${row}")
+            String state = row[4]
+            if (state != "FINISHED" && state != "CANCELLED") {
+                haveError = true
+            }
+            if (haveError && message != null && row[5].contains(message)) {
+                expectMessage = false
+            }
+        }
+        (haveError & expectMessage)

Review Comment:
   bitwise and ?



##########
regression-test/suites/backup_restore/test_backup_restore_schema_not_consist.groovy:
##########
@@ -0,0 +1,160 @@
+// 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.apache.doris.regression.suite.ClusterOptions
+
+suite('test_backup_restore_schema_not_consist', 'docker') {
+    String suiteName = "test_backup_restore_schema_not_consist"
+    String repoName = "${suiteName}_repo"
+    String dbName = "${suiteName}_db"
+    String snapshotName = "${suiteName}_snapshot_" + 
UUID.randomUUID().toString().replace('-', '')
+
+    def isOldSchema = { res -> Boolean
+        return res[0][1].contains("`k` int NULL")
+    }
+    def isNewSchema = { res -> Boolean
+        return res[0][1].contains("`k1` int NULL")
+    }
+
+    docker {
+        def syncer = getSyncer()
+        syncer.createS3Repository(repoName)
+        sql "CREATE DATABASE IF NOT EXISTS ${dbName}"
+        sql "DROP TABLE IF EXISTS ${dbName}.t1"
+        sql "DROP TABLE IF EXISTS ${dbName}.t2"
+        sql """
+            CREATE TABLE IF NOT EXISTS ${dbName}.t1(
+              `k` int NULL,
+              `v` int NULL
+            ) ENGINE = OLAP
+            DISTRIBUTED BY HASH(k) BUCKETS 4
+            PROPERTIES (
+              "replication_num" = "3"
+            );
+        """
+        sql """
+            CREATE TABLE IF NOT EXISTS ${dbName}.t2(
+              `k` int NULL,
+              `v` int NULL
+            ) ENGINE = OLAP
+            DISTRIBUTED BY HASH(k) BUCKETS 4
+            PROPERTIES (
+              "replication_num" = "3"
+            );
+        """
+        sql """
+            insert into ${dbName}.t1 values (1, 1), (2, 2), (3, 3);
+        """
+        sql """
+            insert into ${dbName}.t2 values (4, 4), (5, 5), (6, 6);
+        """
+
+        sql """
+            BACKUP SNAPSHOT ${dbName}.${snapshotName}
+            TO `${repoName}`
+            ON (t1, t2)
+        """
+        syncer.waitSnapshotFinish(dbName)
+
+        def snapshot = syncer.getSnapshotTimestamp(repoName, snapshotName)
+        assertTrue(snapshot != null)
+
+        sql " drop table ${dbName}.t1 "
+        sql " drop table ${dbName}.t2 "
+
+        sql """
+            CREATE TABLE IF NOT EXISTS ${dbName}.t1(
+              `k1` int NULL,
+              `v1` int NULL
+            ) ENGINE = OLAP
+            DISTRIBUTED BY HASH(k1) BUCKETS 4
+            PROPERTIES (
+              "replication_num" = "3"
+            );
+        """
+        sql """
+            CREATE TABLE IF NOT EXISTS ${dbName}.t2(
+              `k1` int NULL,
+              `v1` int NULL
+            ) ENGINE = OLAP
+            DISTRIBUTED BY HASH(k1) BUCKETS 4
+            PROPERTIES (
+              "replication_num" = "3"
+            );
+        """
+        def res = sql " show create table ${dbName}.t1 "
+        assertTrue(isNewSchema(res))
+        res = sql " show create table ${dbName}.t2 "
+        assertTrue(isNewSchema(res))
+        sql """
+            RESTORE SNAPSHOT ${dbName}.${snapshotName}
+            FROM `${repoName}`
+            ON ( `t1`, `t2`)
+            PROPERTIES
+            (
+                "backup_timestamp" = "${snapshot}",
+                "reserve_replica" = "true"
+            )
+        """
+        syncer.waitRestoreError(dbName, "already exist but with different 
schema")
+        res = sql " show create table ${dbName}.t1 "
+        assertTrue(isNewSchema(res))
+        res = sql " show create table ${dbName}.t2 "
+        assertTrue(isNewSchema(res))

Review Comment:
   1. add atomic_restore property
   2. check master/follower table existence, is new schema



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to