Skip to content

Commit

Permalink
fix: 修复恢复数据时出现异常的问题 TencentBlueKing#6968
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu committed Sep 18, 2024
1 parent 7fde93e commit 2db9a5f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (r *RestoreDBSForFullComp) PreCheck() error {
}

// GetRestorePath 获取这次恢复路径
// 全量备份恢复的路径的优先级:app_setting表[RESTORE_PATH] > app_setting表[DATA_PATH] > 默认
// 全量备份恢复的路径的优先级:app_setting表[RESTORE_PATH] > 默认
func (r *RestoreDBSForFullComp) GetRestorePath() error {
var infos []AppSettingInfo
checkSQL := fmt.Sprintf(
Expand All @@ -154,17 +154,21 @@ func (r *RestoreDBSForFullComp) GetRestorePath() error {
if err := r.LocalDB.Queryx(&infos, checkSQL); err != nil {
return fmt.Errorf("select APP_SETTING failed: %v", err)
}
if infos[0].RestorePath.Valid && infos[0].RestorePath.String != "" {
r.RestoreDataPath = infos[0].RestorePath.String
r.RestoreLogPath = infos[0].RestorePath.String
return nil
}
if infos[0].DataPath.Valid && infos[0].LogPath.Valid &&
infos[0].DataPath.String != "" && infos[0].LogPath.String != "" {
r.RestoreDataPath = infos[0].DataPath.String
r.RestoreLogPath = infos[0].LogPath.String
return nil
// 如果aap_setting没有记录,则走默认
if len(infos) > 0 {
if infos[0].RestorePath.Valid && infos[0].RestorePath.String != "" {
r.RestoreDataPath = infos[0].RestorePath.String
r.RestoreLogPath = infos[0].RestorePath.String
return nil
}
if infos[0].DataPath.Valid && infos[0].LogPath.Valid &&
infos[0].DataPath.String != "" && infos[0].LogPath.String != "" {
r.RestoreDataPath = infos[0].DataPath.String
r.RestoreLogPath = infos[0].LogPath.String
return nil
}
}
// 获取默认值
if defaultPath, err := r.LocalDB.GetDefaultPath(); err != nil {
return fmt.Errorf("get default path failed: %v", err)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from backend.flow.engine.bamboo.scene.sqlserver.base_flow import BaseFlow
from backend.flow.engine.bamboo.scene.sqlserver.common_sub_flow import (
build_always_on_sub_flow,
clone_configs_sub_flow,
install_sqlserver_sub_flow,
install_surrounding_apps_sub_flow,
sync_dbs_for_cluster_sub_flow,
Expand Down Expand Up @@ -186,6 +187,18 @@ def run_flow(self):
)
)

# 先做克隆周边配置
cluster_sub_pipeline.add_sub_pipeline(
sub_flow=clone_configs_sub_flow(
uid=self.data["uid"],
root_id=self.root_id,
source_host=Host(ip=master_instance.machine.ip, bk_cloud_id=cluster.bk_cloud_id),
source_port=master_instance.port,
target_host=Host(**info["new_slave_host"]),
target_port=master_instance.port,
)
)

# 删除随机账号
cluster_sub_pipeline.add_act(
act_name=_("drop job user"),
Expand Down

0 comments on commit 2db9a5f

Please sign in to comment.