Previously when creating repository, FE would not do connectivity check. It might result in confusing error when using backup restore. pick #38350 Co-authored-by: AlexYue <yj976240184@gmail.com>
This commit is contained in:
@ -91,7 +91,6 @@ public class BackupHandler extends MasterDaemon implements Writable {
|
||||
public static final int SIGNATURE_VERSION = 1;
|
||||
public static final Path BACKUP_ROOT_DIR = Paths.get(Config.tmp_dir, "backup").normalize();
|
||||
public static final Path RESTORE_ROOT_DIR = Paths.get(Config.tmp_dir, "restore").normalize();
|
||||
|
||||
private RepositoryMgr repoMgr = new RepositoryMgr();
|
||||
|
||||
// this lock is used for updating dbIdToBackupOrRestoreJobs
|
||||
@ -220,6 +219,10 @@ public class BackupHandler extends MasterDaemon implements Writable {
|
||||
ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
|
||||
"Failed to create repository: " + st.getErrMsg());
|
||||
}
|
||||
if (!repo.ping()) {
|
||||
ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
|
||||
"Failed to create repository: failed to connect to the repo");
|
||||
}
|
||||
}
|
||||
|
||||
public void alterRepository(AlterRepositoryStmt stmt) throws DdlException {
|
||||
|
||||
@ -368,6 +368,9 @@ public class Repository implements Writable {
|
||||
// Check if this repo is available.
|
||||
// If failed to connect this repo, set errMsg and return false.
|
||||
public boolean ping() {
|
||||
if (FeConstants.runningUnitTest) {
|
||||
return true;
|
||||
}
|
||||
// for s3 sdk, the headObject() method does not support list "dir",
|
||||
// so we check FILE_REPO_INFO instead.
|
||||
String path = location + "/" + joinPrefix(PREFIX_REPO, name) + "/" + FILE_REPO_INFO;
|
||||
|
||||
Reference in New Issue
Block a user