Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions dbm-services/mysql/db-simulation/app/service/simulation_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bsm/redislock"
"github.com/redis/go-redis/v9"
"github.com/samber/lo"
"gorm.io/gorm"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

util "dbm-services/common/go-pubpkg/cmutil"
Expand Down Expand Up @@ -200,16 +201,29 @@ func reloadRunningTaskFromdb() {
var tks []model.TbSimulationTask
if err := model.DB.Model(model.TbSimulationTask{}).Where(
//nolint
"phase not in (?) and create_time > DATE_SUB(NOW(),INTERVAL 6 HOUR) and time_to_sec(timediff(heartbeat_time,now())) > ? ",
"phase not in (?) and create_time > DATE_SUB(NOW(),INTERVAL 2 HOUR) and time_to_sec(timediff(now(),heartbeat_time)) > ? ",
[]string{model.PhaseDone, model.PhaseReloading}, HeartbeatInterval).Scan(&tks).Error; err != nil {
logger.Error("get running task failed %s", err.Error())
return
}
if len(tks) == 0 {
var reRunTask []model.TbSimulationTask
// 可能已经重试成功了,但是version ID 已经变了
for _, tk := range tks {
var cks model.TbSimulationTask
if err := model.DB.Model(model.TbSimulationTask{}).Where("bill_task_id = ? and phase = ? and status = ?",
tk.BillTaskId, model.PhaseDone, model.TaskSuccess).First(&cks).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
reRunTask = append(reRunTask, tk)
continue
}
}
logger.Info("task %s already run success", tk.TaskId)
}
if len(reRunTask) == 0 {
logger.Info("no need reload running task")
return
}
for _, tk := range tks {
for _, tk := range reRunTask {
var err error
var req model.TbRequestRecord
var p ReloadParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
"dbm-services/common/go-pubpkg/logger"
)

// AnalyzeConcurrency 解析并发度
const AnalyzeConcurrency = 10

// DoParseRelationDbs parse relation db from sql file
func (tf *TmysqlParseFile) DoParseRelationDbs(version string) (createDbs, relationDbs []string, dumpAll bool,
err error) {
Expand All @@ -45,14 +48,12 @@ func (tf *TmysqlParseFile) DoParseRelationDbs(version string) (createDbs, relati
}
// 最后删除临时目录,不会返回错误
defer tf.delTempDir()

errChan := make(chan error, 1)
logger.Info("all sqlfiles download ok ~")
alreadExecutedSqlfileChan := make(chan string, len(tf.Param.FileNames))

go func() {
if err = tf.Execute(alreadExecutedSqlfileChan, version); err != nil {
logger.Error("failed to execute tmysqlparse: %s", err.Error())
errChan <- err
}
close(alreadExecutedSqlfileChan)
}()
Expand All @@ -78,10 +79,11 @@ func (tf *TmysqlParseFile) DoParseRelationDbs(version string) (createDbs, relati
func (t *TmysqlParse) doParseInchan(alreadExecutedSqlfileCh chan string,
mysqlVersion string) (createDbs []string, relationDbs []string, dumpAll bool, err error) {
var errs []error
c := make(chan struct{}, 10)
errChan := make(chan error, 5)
c := make(chan struct{}, AnalyzeConcurrency)
errChan := make(chan error)
wg := &sync.WaitGroup{}
stopChan := make(chan struct{})
// stopchan len 必须要和 AnalyzeConcurrency 保持一致
stopChan := make(chan struct{}, AnalyzeConcurrency)

for sqlfile := range alreadExecutedSqlfileCh {
wg.Add(1)
Expand All @@ -93,8 +95,11 @@ func (t *TmysqlParse) doParseInchan(alreadExecutedSqlfileCh chan string,
if err != nil {
errChan <- err
}
// 如果有dumpall 则直接返回退出,不在继续分析
if dumpAllDbs {
dumpAll = true
<-c
wg.Done()
stopChan <- struct{}{}
}
t.mu.Lock()
Expand Down Expand Up @@ -132,7 +137,6 @@ func (t *TmysqlParse) analyzeRelationDbs(inputfileName, mysqlVersion string) (
logger.Error("panic error:%v,stack:%s", r, string(debug.Stack()))
}
}()
t.result[inputfileName] = &CheckInfo{}
f, err := os.Open(t.getAbsoutputfilePath(inputfileName, mysqlVersion))
if err != nil {
logger.Error("open file failed %s", err.Error())
Expand Down
8 changes: 4 additions & 4 deletions dbm-services/mysql/db-simulation/app/syntax/syntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ const DdlMapFileSubffix = ".tbl.map"

// Do 运行语法检查 For SQL 文件
func (tf *TmysqlParseFile) Do(dbtype string, versions []string) (result map[string]*CheckInfo, err error) {
logger.Info("doing....")
tf.mu = sync.Mutex{}
tf.mu.Lock()
tf.result = make(map[string]*CheckInfo)
tf.tmpWorkdir = tf.BaseWorkdir
tf.mu = sync.Mutex{}

tf.mu.Unlock()
if !tf.IsLocalFile {
if err = tf.Init(); err != nil {
logger.Error("Do init failed %s", err.Error())
Expand All @@ -142,7 +142,7 @@ func (tf *TmysqlParseFile) Do(dbtype string, versions []string) (result map[stri
}

func (tf *TmysqlParseFile) doSingleVersion(dbtype string, mysqlVersion string) (err error) {
errChan := make(chan error, 1)
errChan := make(chan error, len(tf.Param.FileNames))
alreadExecutedSqlfileChan := make(chan string, len(tf.Param.FileNames))
signalChan := make(chan struct{})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ func (c *SemanticDumpSchemaComp) getDumpdbs(alldbs []string, version string) (re
finaldbs = append(finaldbs, db)
}
} else {
if len(lo.Intersect(alldbs, c.Params.ParseCreateDbs)) > 0 {
err = fmt.Errorf("create dbs %v,已经存在目标实例中", c.Params.ParseCreateDbs)
return nil, err
}
for _, f := range c.Params.ExecuteObjects {
var realexcutedbs []string
// 获得目标库 因为是通配符 所以需要获取完整名称
Expand All @@ -226,7 +222,9 @@ func (c *SemanticDumpSchemaComp) getDumpdbs(alldbs []string, version string) (re
realexcutedbs = util.FilterOutStringSlice(intentionDbs, ignoreDbs)
finaldbs = append(finaldbs, realexcutedbs...)
}
createSQLExistDbs := lo.Intersect(alldbs, c.Params.ParseCreateDbs)
finaldbs = append(finaldbs, c.Params.ParseNeedDumpDbs...)
finaldbs = append(finaldbs, createSQLExistDbs...)
}
logger.Info("dump dbs:%v", finaldbs)
return finaldbs, nil
Expand Down
2 changes: 1 addition & 1 deletion dbm-ui/backend/env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
# 标准运维项目 ID
BK_SOPS_PROJECT_ID = get_type_env(key="BK_SOPS_PROJECT_ID", _type=int, default=1)
# 标准运维更新window机器的模板ID
UPDATE_WINDOW_GSE_CONFIG = get_type_env(key="UPDATE_WINDOW_GSE_CONFIG", _type=int, default=1)
UPDATE_WINDOW_GSE_CONFIG = get_type_env(key="UPDATE_WINDOW_GSE_CONFIG", _type=int)

# Bamboo
ENABLE_CLEAN_EXPIRED_BAMBOO_TASK = get_type_env(key="ENABLE_CLEAN_EXPIRED_BAMBOO_TASK", _type=bool, default=False)
Expand Down
3 changes: 2 additions & 1 deletion dbm-ui/frontend/src/components/db-table/OriginalTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
(e: 'clearSearch'): void;
}
interface Props {
columns: InstanceType<typeof Table>['$props']['columns'];
columns?: InstanceType<typeof Table>['$props']['columns'];
isAnomalies?: boolean;
isSearching?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
columns: undefined,
isAnomalies: false,
isSearching: false,
});
Expand Down
4 changes: 0 additions & 4 deletions dbm-ui/frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ import getTicketRoutes from '@views/ticket-center/routes';
import getTicketCooperationSettingRoutes from '@views/ticket-cooperation-setting/routes';
import getTicketFlowSettingBizRoutes from '@views/ticket-flow-setting-biz/routes';
import getTicketFlowSettingGlobalRoutes from '@views/ticket-flow-setting-global/routes';
// import getTicketManageRoutes from '@views/ticket-manage/routes';
// import getTicketSelfApplyRoutes from '@views/ticket-self-apply/routes';
// import getTicketSelfManageRoutes from '@views/ticket-self-manage/routes';
// import getTicketSelfTodoRoutes from '@views/ticket-self-todo/routes';
import getVersionFilesRoutes from '@views/version-files/routes';
import getWhitelistRoutes from '@views/whitelist/routes';

Expand Down
14 changes: 7 additions & 7 deletions dbm-ui/frontend/src/services/source/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ export function updatePackage(params: {
id: number;
priority?: number;
enable?: boolean;
name: string;
version: string;
pkg_type: string;
db_type: string;
path: string;
size: number;
md5: string;
name?: string;
version?: string;
pkg_type?: string;
db_type?: string;
path?: string;
size?: number;
md5?: string;
allow_biz_ids?: number[];
mode?: string;
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
</DbForm>
</template>
<script lang="tsx">
import type { Column } from 'bkui-vue/lib/table/props';
// import _ from 'lodash';
import { useI18n } from 'vue-i18n';

import { getLevelConfig } from '@services/source/configs';
Expand All @@ -46,9 +44,9 @@
index: number;
};

export default {
defineOptions({
name: 'ParameterTable',
};
});
</script>

<script setup lang="tsx">
Expand Down Expand Up @@ -101,10 +99,10 @@
// 配合 controlShow 控制当前行显示隐藏
const lockTipsList = computed(() => Array.from({ length: props.data.length }, () => false));

const columns: Column[] = [{
const columns = [{
label: t('参数项'),
field: 'conf_name',
showOverflowTooltip: false,
minWidth: 300,
render: ({ cell, data, index }: TableColumn) => {
if (data.op_type === 'add') {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
{
label: t('参数项'),
field: 'conf_name',
minWidth: 300,
render: ({ data }: {data: ParameterConfigItem}) => (
<>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
{
label: t('集群'),
field: 'master_domain',
minWidth: 250,
},
{
label: t('类型'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
},
{
label: t('操作'),
field: 'action',
width: 220,
fixed: 'right',
render: ({ data }: { data: PartitionModel }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
const router = useRouter();
const globalBizsStore = useGlobalBizs();
const { handleDisableCluster, handleEnableCluster, handleDeleteCluster } = useOperateClusterBasic(
ClusterTypes.REDIS,
ClusterTypes.REDIS_INSTANCE,
{
onSuccess: () => fetchData(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@
},
{
label: t('操作'),
field: 'action',
width: 220,
fixed: 'right',
render: ({ data }: { data: PartitionModel }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const create = (options = {} as { exclude: string[] }) => {
const serachList = [
{
name: t('单号'),
id: 'id',
id: 'ids',
},
{
name: t('单据类型'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
}

.demand-info-item-value {
display: ruby;
overflow: hidden;
color: @title-color;
text-overflow: ellipsis;
Expand Down
Loading
Loading