From c6f8b1b2eea5613b318ca00d5487eac18f5b2442 Mon Sep 17 00:00:00 2001 From: xueweizhang Date: Sat, 9 Dec 2023 01:46:54 +0800 Subject: [PATCH] [fix](repository) the exist repo_file must contails same name with new repo (#27668) The user manually adjusted the 'name' field in the __repo_info file under the repo file on S3, but did not modify the folder name. This led to an issue when the user created a repo with the same name as the folder in a certain cluster. The system parsed the 'name' field in the existing __repo_info and used an incorrect name, causing the subsequent repo to be unusable. A judgment has been added here: the 'name' field in the __repo_info must be the same as the new repo's name, otherwise, an error will be reported. --- .../src/main/java/org/apache/doris/backup/Repository.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java b/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java index a236ba3c30..58dff0d732 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java @@ -262,6 +262,11 @@ public class Repository implements Writable { byte[] bytes = Files.readAllBytes(Paths.get(localFilePath)); String json = new String(bytes, StandardCharsets.UTF_8); JSONObject root = (JSONObject) JSONValue.parse(json); + if (name.compareTo((String) root.get("name")) != 0) { + return new Status(ErrCode.COMMON_ERROR, + "Invalid repository __repo_info, expected repo '" + name + "', but get name '" + + (String) root.get("name") + "' from " + repoInfoFilePath); + } name = (String) root.get("name"); createTime = TimeUtils.timeStringToLong((String) root.get("create_time")); if (createTime == -1) {